Changeset 8 in josm for src/org/openstreetmap/josm/data/osm/Key.java
- Timestamp:
- 2005-10-03T04:18:02+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/osm/Key.java
r7 r8 2 2 3 3 import java.util.Collection; 4 import java.util.HashMap; 4 5 import java.util.LinkedList; 6 import java.util.Map; 7 8 import org.openstreetmap.josm.data.osm.visitor.Visitor; 5 9 6 10 … … 15 19 * The key's name 16 20 */ 17 public String name;21 public final String name; 18 22 23 /** 24 * All keys are stored here. 25 */ 26 private static Map<String, Key> allKeys = new HashMap<String, Key>(); 27 28 /** 29 * Generate a key with the given name. You cannot call this directly but 30 * have to use the static constructor. This makes sure, you get every key 31 * only once. 32 */ 33 private Key(String name) { 34 this.name = name; 35 } 36 37 /** 38 * Get an instance of the key with the given name. 39 * @param name The name of the key to get. 40 * @return An shared instance of the key with the given name. 41 */ 42 public static Key get(String name) { 43 Key key = allKeys.get(name); 44 if (key == null) { 45 key = new Key(name); 46 allKeys.put(name, key); 47 } 48 return key; 49 } 50 19 51 /** 20 52 * Return an empty list, since keys cannot have nodes. … … 39 71 return name.hashCode(); 40 72 } 73 74 @Override 75 public void visit(Visitor visitor) { 76 visitor.visit(this); 77 } 41 78 }
Note:
See TracChangeset
for help on using the changeset viewer.