@Override public boolean containsKey(Object o) { return o instanceof Right && getValue(((Right) o).ordinal()) != null; }
@Override public boolean equals(Object o) { if (!(o instanceof RightMap)) { return super.equals(o); } RightMap rmap = (RightMap) o; // Key types match, compare each value for (int i = 0; i < Right.size(); i++) { Object val = getValue(i); Object rval = rmap.getValue(i); if (rval != val && (rval == null || !rval.equals(val))) { return false; } } return true; }
@Override public String toString() { StringBuilder sb = new StringBuilder("["); boolean first = true; for (int i = 0; i < rights.size(); i++) { if (getValue(i) != null) { if (first) { first = false; } else { sb.append(", "); } sb.append(Right.get(i).getName()) .append(" = ") .append(unmaskNull(getValue(i)).toString()); } } sb.append("]"); return sb.toString(); }
@Override public V get(Object o) { return (o instanceof Right ? unmaskNull(getValue(((Right) o).ordinal())) : null); }
@Override @SuppressWarnings("unchecked") public void putAll(Map<? extends Right, ? extends V> map) { if (map instanceof RightMap) { RightMap<? extends V> rmap = (RightMap<? extends V>) map; for (int i = 0; i < Right.size(); i++) { updateValue(i, rmap.getValue(i)); } } else { super.putAll(map); } }