Enum Ordinate

 1 /*
 2  * Copyright (c) 2018 Felix Obermaier
 3  *
 4  * All rights reserved. This program and the accompanying materials
 5  * are made available under the terms of the Eclipse Public License 2.0
 6  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 7  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 8  * and the Eclipse Distribution License is available at
 9  *
10  * http://www.eclipse.org/org/documents/edl-v10.php.
11  */
12  
13 package org.locationtech.jts.io;
14  
15 import java.util.EnumSet;
16  
17 /**
18  * An enumeration of possible Well-Known-Text or Well-Known-Binary ordinates.
19  * <p>
20  * Intended to be used as an {@code EnumSet<Ordinate>}, optimized create methods have been provided for {@link #createXY()}, {@link #createXYM()}, {@link #createXYZ()} and {@link #createXYZM()}.
21  */
22 public enum Ordinate {
23   /**
24    * X-ordinate
25    */
26   X,
27   /**
28    * Y-ordinate
29    */
30   Y,
31   /**
32    * Z-ordinate
33    */
34   Z,
35   /**
36    * Measure-ordinate
37    */
38   M;
39  
40   private static final EnumSet<Ordinate> XY = EnumSet.of(X, Y);
41   private static final EnumSet<Ordinate> XYZ = EnumSet.of(X, Y, Z);
42   private static final EnumSet<Ordinate> XYM = EnumSet.of(X, Y, M);
43   private static final EnumSet<Ordinate> XYZM = EnumSet.of(X, Y, Z, M);
44  
45   /**
46    * EnumSet of X and Y ordinates, a copy is returned as EnumSets are not immutable.
47    * @return EnumSet of X and Y ordinates.
48    */
49   public static EnumSet<Ordinate> createXY() { return XY.clone(); }
50   /**
51    * EnumSet of XYZ ordinates, a copy is returned as EnumSets are not immutable.
52    * @return EnumSet of X and Y ordinates.
53    */
54   public static EnumSet<Ordinate> createXYZ() { return XYZ.clone(); }
55   /**
56    * EnumSet of XYM ordinates, a copy is returned as EnumSets are not immutable.
57    * @return EnumSet of X and Y ordinates.
58    */
59   public static EnumSet<Ordinate> createXYM() { return XYM.clone(); }
60   /**
61    * EnumSet of XYZM ordinates, a copy is returned as EnumSets are not immutable.
62    * @return EnumSet of X and Y ordinates.
63    */
64   public static EnumSet<Ordinate> createXYZM() { return XYZM.clone(); }
65 }
66