public void retainAll(Key key) { Key shared = new DefaultKeyList(); shared.addAll(key); retain(this, shared); }
/** * 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(); } } } }