public static Location locationFor(String name) {
if (locations.isEmpty()) {
// can't use valueOf which throws IllegalArgumentException
for (Location location : values())
locations.putIfAbsent(location.getName(), location);
}
locations.putIfAbsent(name.toString(/* null-check */), new Location() {
public String getName() { return name; }
public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }
});
return locations.get(name);
}
Gets a location object with the given name. The following
property must hold: {@code locationFor(x) ==
locationFor(y)} if and only if {@code x.equals(y)}.
The returned location will be an output location if and only if
name ends with {@code "_OUTPUT"}. |