View Javadoc
1   package org.djutils.immutablecollections;
2   
3   /**
4    * Indicate whether the immutable collection contains a COPY of the collection (neither changeable by the user of the immutable
5    * collection, nor by anyone holding a pointer to the original collection), or a WRAP for the original collection (not
6    * changeable by the user of the immutable collection, but can be changed by anyone holding a pointer to the original collection
7    * that is wrapped).
8    * <p>
9    * Copyright (c) 2016-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
10   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
11   * distributed under a three-clause BSD-style license, which can be found at
12   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>.
13   * </p>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
16   */
17  public enum Immutable
18  {
19      /**
20       * A copy is neither changeable by the user of the immutable collection, nor by anyone holding a pointer to the original
21       * collection that is put into the immutable collection.
22       */
23      COPY,
24  
25      /**
26       * A wrapped immutable collection is not changeable by the user of the immutable collection, but can be changed by anyone
27       * holding a pointer to the original collection that is wrapped.
28       */
29      WRAP;
30  
31      /**
32       * @return whether the immutable is a COPY
33       */
34      public boolean isCopy()
35      {
36          return this.equals(COPY);
37      }
38  
39      /**
40       * @return whether the immutable is a WRAP
41       */
42      public boolean isWrap()
43      {
44          return this.equals(WRAP);
45      }
46  
47  }