Changeset 12018 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r11349 r12018 39 39 } 40 40 41 /** 42 * Returns the API type name / JOSM display name. 43 * @return the API type name / JOSM display name 44 */ 41 45 public String getAPIName() { 42 46 return apiTypeName; 43 47 } 44 48 49 /** 50 * Returns the OSM class for data values, or null. 51 * @return the OSM class for data values, or null 52 */ 45 53 public Class<? extends OsmPrimitive> getOsmClass() { 46 54 return osmClass; 47 55 } 48 56 57 /** 58 * Returns the data class. 59 * @return the data class 60 */ 49 61 public Class<? extends PrimitiveData> getDataClass() { 50 62 return dataClass; 51 63 } 52 64 65 /** 66 * Returns enum value from API type name / JOSM display name, case sensitive. 67 * @param typeName API type name / JOSM display name, case sensitive 68 * @return matching enum value 69 * @throws IllegalArgumentException if the type name does not match any valid type 70 * @see #from(String) 71 */ 53 72 public static OsmPrimitiveType fromApiTypeName(String typeName) { 54 73 for (OsmPrimitiveType type : OsmPrimitiveType.values()) { … … 72 91 } 73 92 93 /** 94 * Returns enum value from API type name / JOSM display name, case insensitive. 95 * @param value API type name / JOSM display name, case insensitive 96 * @return matching enum value or null 97 * @see #fromApiTypeName 98 */ 74 99 public static OsmPrimitiveType from(String value) { 75 if (value == null) return null;76 100 for (OsmPrimitiveType type: values()) { 77 101 if (type.getAPIName().equalsIgnoreCase(value)) … … 81 105 } 82 106 107 /** 108 * Returns the values matching real OSM API data types (node, way, relation). 109 * @return the values matching real OSM API data types (node, way, relation) 110 */ 83 111 public static Collection<OsmPrimitiveType> dataValues() { 84 112 return DATA_VALUES; 85 113 } 86 114 115 /** 116 * Constructs a new primitive instance (node, way or relation) without version. 117 * @param uniqueId the unique id 118 * @param allowNegative {@code true} to allow negative id 119 * @return a new primitive instance (node, way or relation) 120 * @throws IllegalArgumentException if uniqueId < 0 and allowNegative is false 121 */ 87 122 public OsmPrimitive newInstance(long uniqueId, boolean allowNegative) { 88 123 switch (this) { … … 98 133 } 99 134 135 /** 136 * Constructs a new primitive instance (node, way or relation) with given version. 137 * @param id The id. Must be >= 0 138 * @param version The version 139 * @return a new primitive instance (node, way or relation) with given version 140 * @throws IllegalArgumentException if id < 0 141 * @since 12018 142 */ 143 public OsmPrimitive newVersionedInstance(long id, int version) { 144 switch (this) { 145 case NODE: 146 return new Node(id, version); 147 case WAY: 148 return new Way(id, version); 149 case RELATION: 150 return new Relation(id, version); 151 default: 152 throw new AssertionError(); 153 } 154 } 155 100 156 @Override 101 157 public String toString() {
Note:
See TracChangeset
for help on using the changeset viewer.