/** * Create a new id by possibly removing tags from the list. This operation will:<br/> * 1) remove keys as specified by the parameters<br/> * 2) dedup entries that have the same key, the first value associated with the key will be the one kept,<br/> * 3) sort the list by the tag keys. * * @param keys * Set of keys to either keep or remove. * @param keep * If true, then the new id can only have tag keys in the provided set. Otherwise the new id * can only have ids not in that set. * @return * New identifier after applying the rollup. */ DefaultId rollup(Set<String> keys, boolean keep) { if (tags.isEmpty()) { return this; } else { Map<String, String> ts = new TreeMap<>(); for (Tag t : tags) { if (keys.contains(t.key()) == keep && !ts.containsKey(t.key())) { ts.put(t.key(), t.value()); } } return new DefaultId(name, ArrayTagSet.create(ts)); } }
/** * Create a new id by possibly removing tags from the list. This operation will:<br/> * 1) remove keys as specified by the parameters<br/> * 2) dedup entries that have the same key, the first value associated with the key will be the one kept,<br/> * 3) sort the list by the tag keys. * * @param keys * Set of keys to either keep or remove. * @param keep * If true, then the new id can only have tag keys in the provided set. Otherwise the new id * can only have ids not in that set. * @return * New identifier after applying the rollup. */ DefaultId rollup(Set<String> keys, boolean keep) { if (tags.isEmpty()) { return this; } else { Map<String, String> ts = new TreeMap<>(); for (Tag t : tags) { if (keys.contains(t.key()) == keep && !ts.containsKey(t.key())) { ts.put(t.key(), t.value()); } } return new DefaultId(name, ArrayTagSet.create(ts)); } }