1 package charactermanaj.model;
3 import java.util.Collections;
4 import java.util.Comparator;
5 import java.util.HashMap;
8 public class CustomLayerOrderKey implements Comparable<CustomLayerOrderKey> {
10 private final String id;
12 private final String displayName;
14 private final Map<String, String> localizedNames;
16 public static final String DEFAULT_NAME_KEY = "";
18 public CustomLayerOrderKey(String id, String name, Map<String, String> localizedNames) {
19 if (id == null || name == null) {
20 throw new NullPointerException("id and name is required.");
23 this.displayName = name;
24 if (localizedNames == null) {
25 localizedNames = Collections.emptyMap();
27 this.localizedNames = Collections.unmodifiableMap(new HashMap<String, String>(localizedNames));
30 public String getId() {
34 public String getDisplayName() {
38 public Map<String, String> getLocalizedNames() {
39 return localizedNames;
43 public int hashCode() {
46 result = prime * result + ((id == null) ? 0 : id.hashCode());
51 public boolean equals(Object obj) {
56 if (getClass() != obj.getClass())
58 CustomLayerOrderKey other = (CustomLayerOrderKey) obj;
62 } else if (!id.equals(other.id))
70 public static final Comparator<CustomLayerOrderKey> COMPARATOR = new Comparator<CustomLayerOrderKey>() {
72 public int compare(CustomLayerOrderKey o1, CustomLayerOrderKey o2) {
74 // ※ ソート順でマップ化した場合、表示名が異なるがIDが同一のものができうるため
75 // ツリーマップ化などを使う場合はロジックでID重複を防ぐ必要がある。
76 int ret = o1.displayName.compareTo(o2.displayName);
78 ret = o1.id.compareTo(o2.id);
85 public int compareTo(CustomLayerOrderKey o) {
86 return COMPARATOR.compare(this, o);
90 public String toString() {