/** * Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute. * @return Every attribute modifier. */ public Set<WrappedAttributeModifier> getModifiers() { if (attributeModifiers == null) { @SuppressWarnings("unchecked") Collection<Object> collection = (Collection<Object>) modifier.withType(Collection.class).read(0); // Convert to an equivalent wrapper ConvertedSet<Object, WrappedAttributeModifier> converted = new ConvertedSet<Object, WrappedAttributeModifier>(getSetSafely(collection)) { @Override protected Object toInner(WrappedAttributeModifier outer) { return outer.getHandle(); } @Override protected WrappedAttributeModifier toOuter(Object inner) { return WrappedAttributeModifier.fromHandle(inner); } }; attributeModifiers = new CachedSet<WrappedAttributeModifier>(converted); } return Collections.unmodifiableSet(attributeModifiers); }