public Map<String, UserAttribute> getAttributesMap() { return Collections.transform(getAttributes(), new Transformer<UserAttribute, String>() { @Override public String transform(UserAttribute obj) { return obj.getKey(); } }); }
public Set<String> getAttributeKeys() { return Collections.collect(getAttributes(), new Transformer<UserAttribute, String>() { @Override public String transform(UserAttribute obj) { return obj.getKey(); } }, new HashSet<String>()); }
public void removeAttribute(Predicate<UserAttribute> predicate) { Set<UserAttribute> matchedToRemove = new HashSet<UserAttribute>(); for (UserAttribute a : getAttributes()) { if (predicate.apply(a)) { matchedToRemove.add(a); } } removeMatched(matchedToRemove); }
public UserAttribute findAttributeRecursive(final String key) { UserAttribute found = findAttribute(key); if (found == null) { for (UserAttribute a : getAttributes()) { found = a.findAttributeRecursive(key); if (found != null) { break; } } } return found; }
public UserAttribute findAttributeRecursive(final String key, final String value) { UserAttribute found = findAttribute(key, value); if (found == null) { for (UserAttribute a : getAttributes()) { found = a.findAttributeRecursive(key, value); if (found != null) { break; } } } return found; }
public UserAttribute findAttribute(UserAttribute attribute) { return findAttribute(getAttributes(), UserAttributePredicates.matchEntity(attribute)); }
public Collection<UserAttribute> findAttributesMatchingKey(final String key) { return findAttributesByPredicate(getAttributes(), UserAttributePredicates.matchKey(key)); }
private void removeMatched(Set<UserAttribute> matchedToRemove) { getAttributes().removeAll(matchedToRemove); if (getUser() != null) { UserData user = getUser(); for (UserAttribute a : matchedToRemove) { clearAttribute(user, a); } } }
public UserAttribute findAttribute(final String key) { return findAttribute(getAttributes(), UserAttributePredicates.matchKey(key)); }
public UserAttribute findAttribute(final String key, final String value) { return findAttribute(getAttributes(), UserAttributePredicates.matchKeyValue(key, value)); }
UserAttribute addInternal(UserAttribute a) { if (a.getParent() != null) { a.getParent().getAttributes().remove(a); } getAttributes().add(a); if (getUser() != null) { getUser().addChild(a); } a.setUser(getUser()); a.setParent(getChildParent()); return a; }