@Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getMetaType().hashCode(); for (String key : getMetaType().keySet()) { Object value = contents.get(key); if (value != null) cachedHashCode += value.hashCode(); } return cachedHashCode; }
@Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getMetaType().hashCode(); for (String key : getMetaType().keySet()) { Object value = contents.get(key); if (value != null) cachedHashCode += value.hashCode(); } return cachedHashCode; }
/** * Validates the key against the composite type * * @param key the key to check * @return the meta type * @throws IllegalArgumentException for a null or empty key or when * the key not a valid item name for the composite type */ private MetaType validateKey(String key) { if (key == null || key.length() == 0) throw new IllegalArgumentException("null or empty key"); CompositeMetaType metaType = getMetaType(); MetaType result = metaType.getType(key); if (result == null) throw new IllegalArgumentException("no such item name " + key + " for composite type " + metaType); return result; }
/** * Validates the key against the composite type * * @param key the key to check * @return the meta type * @throws IllegalArgumentException for a null or empty key or when * the key not a valid item name for the composite type */ private MetaType validateKey(String key) { if (key == null || key.length() == 0) throw new IllegalArgumentException("null or empty key"); CompositeMetaType metaType = getMetaType(); MetaType result = metaType.getType(key); if (result == null) throw new IllegalArgumentException("no such item name " + key + " for composite type " + metaType); return result; }
@Override public String toString() { CompositeMetaType metaType = getMetaType(); StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append(": metaType=["); buffer.append(metaType); buffer.append("] items=["); Iterator keys = metaType.keySet().iterator(); while(keys.hasNext()) { Object key = keys.next(); buffer.append(key).append("="); Object value = contents.get(key); buffer.append(value); if (keys.hasNext()) buffer.append(","); } buffer.append("]"); return buffer.toString(); }
@Override public String toString() { CompositeMetaType metaType = getMetaType(); StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append(": metaType=["); buffer.append(metaType); buffer.append("] items=["); Iterator<String> keys = metaType.keySet().iterator(); while(keys.hasNext()) { Object key = keys.next(); buffer.append(key).append("="); Object value = contents.get(key); buffer.append(value); if (keys.hasNext()) buffer.append(","); } buffer.append("]"); return buffer.toString(); }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CompositeValue == false) return false; CompositeValue other = (CompositeValue) obj; if (getMetaType().equals(other.getMetaType()) == false) return false; for (String key : getMetaType().keySet()) { Object thisValue = this.get(key); Object otherValue = other.get(key); if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false) return false; } return true; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CompositeValue == false) return false; CompositeValue other = (CompositeValue) obj; if (getMetaType().equals(other.getMetaType()) == false) return false; for (String key : getMetaType().keySet()) { Object thisValue = this.get(key); Object otherValue = other.get(key); if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false) return false; } return true; }