public class IntersectedPropertySet extends java.lang.Object implements PropertySet
The class calculates the intersectable properties on construction, so changes to the underlying propertysets will not be visible unless refresh() is called. Changes made through this class, however, are tracked, so it won't normally be necessary to call refresh().
EMPTY
Constructor and Description |
---|
IntersectedPropertySet(java.util.List<? extends PropertySet> propertySets) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Property<?> prop) |
<T> T |
get(Property<T> prop)
Returns the intersected value, or null if the values don't match or the property isn't present.
|
int |
getCount() |
protected java.util.Set<Property<?>> |
getIntersectableProperties() |
<T> T |
getOrDefault(Property<T> prop) |
<T> T |
getOrElse(Property<T> prop,
T value)
Get the value for a given
Property , or else fall back to value if it's not present. |
java.util.Collection<Property<?>> |
getProperties() |
java.util.List<PropertyValue> |
getValues() |
protected java.util.List<? extends PropertySet> |
internalObjects() |
protected <T> T |
intersect(Property<T> prop,
boolean orElse,
T elseVal,
T fallback) |
boolean |
isExtended(Property<?> prop)
Returns whether this property set contains a value for the prop, and the prop was actually inherited.
|
boolean |
isInherited(Property<?> prop)
Indicates whether the property was inherited from a parent type.
|
protected <T> boolean |
isPropIntersectable(Property<T> prop) |
java.util.Iterator<PropertyValue> |
iterator() |
void |
merge(PropertySet other,
boolean localOnly)
Merges the values from other collection into this one.
|
protected void |
modifyPossibleProps(Property<?> prop,
boolean remove) |
void |
refresh()
Recalculates the intersection.
|
void |
remove(Property<?> prop) |
<T> void |
set(Property<T> prop,
T value) |
void |
set(PropertyValue propValue) |
protected void |
setImpl(PropertyValue propValue) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, extend, getExtension, newDefaultInstance, newExtension
public IntersectedPropertySet(java.util.List<? extends PropertySet> propertySets)
public void refresh()
protected java.util.List<? extends PropertySet> internalObjects()
public java.util.Iterator<PropertyValue> iterator()
iterator
in interface java.lang.Iterable<PropertyValue>
public <T> T get(Property<T> prop)
get
in interface PropertyValueSource
public boolean contains(Property<?> prop)
contains
in interface PropertyValueSource
public <T> T getOrDefault(Property<T> prop)
getOrDefault
in interface PropertyValueSource
Property.getDefaultValue()
if not present.public <T> T getOrElse(Property<T> prop, T value)
PropertyValueSource
Property
, or else fall back to value if it's not present.getOrElse
in interface PropertyValueSource
prop
- The Property
for which a value is to be retrieved.value
- The value to default to if property isn't present.protected <T> T intersect(Property<T> prop, boolean orElse, T elseVal, T fallback)
protected <T> boolean isPropIntersectable(Property<T> prop)
protected void modifyPossibleProps(Property<?> prop, boolean remove)
public <T> void set(Property<T> prop, T value)
set
in interface MutablePropertyValueSource
public void set(PropertyValue propValue)
set
in interface MutablePropertyValueSource
protected void setImpl(PropertyValue propValue)
public void remove(Property<?> prop)
remove
in interface MutablePropertyValueSource
public java.util.Collection<Property<?>> getProperties()
getProperties
in interface PropertyValueSource
public java.util.List<PropertyValue> getValues()
getValues
in interface PropertyValueSource
public boolean isExtended(Property<?> prop)
PropertySet
isExtended
in interface PropertySet
public boolean isInherited(Property<?> prop)
PropertySet
isInherited
in interface PropertySet
public void merge(PropertySet other, boolean localOnly)
Mergable
merge
in interface Mergable<PropertySet>
merge
in interface MutablePropertyValueSource
protected java.util.Set<Property<?>> getIntersectableProperties()