@Override public TreeKey clone() { return (TreeKey) super.clone(); }
public boolean isEmpty() { return getCardinality() == 0; }
public String getName(Key base) { return getName(); }
public void retainAll(Key key) { Key shared = new DefaultKeyList(); shared.addAll(key); retain(this, shared); }
public boolean contains(Key key) { return indexOf(key) >= 0; }
@Override public boolean equals(Object obj) { // Since this can not be null if (obj == null) { return false; } // Check that that is the same as this // Don't use instanceOf since that breaks inheritance if (!obj.getClass().equals(this.getClass())) { return false; } return compareTo((Key) obj) == 0; }
/** * Utility to remove all the keys from alter that are not in base * * @param alter * The key to remove keys from * @param base * The check key */ protected static void retain(Key alter, Key base) { Iterator<Key> it = alter.iterator(); while (it.hasNext()) { Key sublist = it.next(); if (sublist.canHaveChildren()) { retain(sublist, base); if (sublist.isEmpty()) { it.remove(); } } else { if (!base.contains(sublist)) { it.remove(); } } } }
@Override public String toString() { return getName(); }
public String getRootName() { return getName(); }
@Override public int hashCode() { return getName().hashCode(); }