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-2019 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   * @author <a href="https://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public enum Immutable
19  {
20      /**
21       * A copy is neither changeable by the user of the immutable collection, nor by anyone holding a pointer to the original
22       * collection that is put into the immutable collection.
23       */
24      COPY,
25  
26      /**
27       * A wrapped immutable collection is not changeable by the user of the immutable collection, but can be changed by anyone
28       * holding a pointer to the original collection that is wrapped.
29       */
30      WRAP;
31  
32      /**
33       * @return whether the immutable is a COPY
34       */
35      public boolean isCopy()
36      {
37          return this.equals(COPY);
38      }
39  
40      /**
41       * @return whether the immutable is a WRAP
42       */
43      public boolean isWrap()
44      {
45          return this.equals(WRAP);
46      }
47  
48  }