@Override public StructuredDataType getDataType() { return (StructuredDataType)super.getDataType(); }
@Override public MapFieldValue clone() { MapFieldValue copy = (MapFieldValue) super.clone(); copy.values = new HashMap<K, V>(values.size()); for (Map.Entry<K, V> entry : values.entrySet()) { copy.values.put(entry.getKey().clone(), entry.getValue().clone()); } return copy; }
/** * Checks if another object is equal to this set. * * @param o the object to check for equality with * @return true if o is an instance of WeightedSet and the two encapsulated Maps are equal, false otherwise */ public boolean equals(Object o) { if (!(o instanceof MapFieldValue)) return false; return super.equals(o) && entrySet().equals(((MapFieldValue) o).entrySet()); }
@Override public int compareTo(FieldValue fieldValue) { int comp = super.compareTo(fieldValue); if (comp != 0) { return comp; } //types are equal, this must be of this type MapFieldValue<K,V> rhs = (MapFieldValue<K,V>) fieldValue; if (size() < rhs.size()) { return -1; } else if (size() > rhs.size()) { return 1; } Map.Entry<K,V> [] entries = entrySet().toArray(new Map.Entry[size()]); Map.Entry<K,V> [] rhsEntries = rhs.entrySet().toArray(new Map.Entry[rhs.size()]); Arrays.sort(entries, Comparator.comparing(Map.Entry<K,V>::getKey)); Arrays.sort(rhsEntries, Comparator.comparing(Map.Entry<K,V>::getKey)); for (int i = 0; i < entries.length; i++) { comp = entries[i].getKey().compareTo(rhsEntries[i].getKey()); if (comp != 0) return comp; comp = entries[i].getValue().compareTo(rhsEntries[i].getValue()); if (comp != 0) return comp; } return 0; }
@Override public CollectionDataType getDataType() { return (CollectionDataType) super.getDataType(); }
@Override public MapDataType getDataType() { return (MapDataType)super.getDataType(); }