Class PropertyContainer
- All Implemented Interfaces:
Iterable<PropertyValuePair<?>>,IPropertyContainerConst,IPropertyHolder,IPropertyHolderConst
New instances of this class can be created using forType(StructureType).
A property container is created for a specific structure type. It contains all properties that are defined for that
type as defined by StructureType.getProperties().
It is not possible to set a property that is not defined for the structure type this property container was created
for. Attempting to do so will result in an IllegalArgumentException.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(IPropertyContainerConst propertyContainer) Adds all properties from the given property container to this property container.booleanstatic PropertyContainerforProperties(List<Property<?>> properties) Creates a new property container for the given properties.static PropertyContainerforType(StructureType structureType) Creates a new property container for the given structure type.<T> IPropertyValue<T> getPropertyValue(Property<T> property) Gets the value of the given property.inthashCode()booleanhasProperties(Collection<Property<?>> properties) Checks if this property holder has all the given properties.booleanhasProperty(Property<?> property) Checks if the given property has a value set.@NotNull Iterator<PropertyValuePair<?>> iterator()Returns a read-only iterator over the properties in this container.static PropertyContainerCreates a newPropertyContainerfrom the given properties.static PropertyContainerof(IPropertyContainerConst other) Creates a copy of the given property container.static <A> PropertyContainerType-safe version ofof(Object...)for 1 property.static <A,B> PropertyContainer Type-safe version ofof(Object...)for 2 properties.static <A,B, C> PropertyContainer of(Property<A> property0, A value0, Property<B> property1, B value1, Property<C> property2, C value2) Type-safe version ofof(Object...)for 3 properties.static <A,B, C, D>
PropertyContainerof(Property<A> property0, A value0, Property<B> property1, B value1, Property<C> property2, C value2, Property<D> property3, D value3) Type-safe version ofof(Object...)for 4 properties.static <A,B, C, D, E>
PropertyContainerof(Property<A> property0, A value0, Property<B> property1, B value1, Property<C> property2, C value2, Property<D> property3, D value3, Property<E> property4, E value4) Type-safe version ofof(Object...)for 5 properties.<T> IPropertyValue<T> setPropertyValue(Property<T> property, T value) Sets the value of the given property.<T> IPropertyValue<?> setUntypedPropertyValue(Property<T> property, @Nullable Object value) Sets the value of the given property without type checking.snapshot()Creates a new snapshot of this property container.Returns a read-only spliterator over the properties in this container.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.pim16aap2.animatedarchitecture.core.structures.properties.IPropertyContainerConst
streamMethods inherited from interface nl.pim16aap2.animatedarchitecture.core.structures.properties.IPropertyHolderConst
getRequiredPropertyValue, hasProperties, hasProperties
-
Method Details
-
of
Creates a copy of the given property container.- Parameters:
other- The property container to copy.- Returns:
- A new property container with the same properties as the given property container.
-
setPropertyValue
Sets the value of the given property.- Specified by:
setPropertyValuein interfaceIPropertyHolder- Type Parameters:
T- The type of the property.- Parameters:
property- The property to set the value for.value- The value to set. May benullif the property is nullable.- Returns:
- The previous value of the property, or
nullif the property had no value set. - Throws:
IllegalArgumentException- If the property is not valid for the structure type this property container was created for.
-
setUntypedPropertyValue
public <T> IPropertyValue<?> setUntypedPropertyValue(Property<T> property, @Nullable @Nullable Object value) Sets the value of the given property without type checking.If possible, consider using
setPropertyValue(Property, Object)instead for better type safety.- Parameters:
property- The property to set the value for.value- The value to set. May benullif the property is nullable.- Throws:
ClassCastException- If the value cannot be cast to the type of the property.
-
getPropertyValue
Description copied from interface:IPropertyHolderConstGets the value of the given property.- Specified by:
getPropertyValuein interfaceIPropertyHolderConst- Type Parameters:
T- The type of the property.- Parameters:
property- The property to get the value of.- Returns:
- The value of the property.
-
hasProperty
Description copied from interface:IPropertyHolderConstChecks if the given property has a value set.- Specified by:
hasPropertyin interfaceIPropertyHolderConst- Parameters:
property- The property to check.- Returns:
trueif the property has a value set,falseotherwise.
-
hasProperties
Description copied from interface:IPropertyHolderConstChecks if this property holder has all the given properties.- Specified by:
hasPropertiesin interfaceIPropertyHolderConst- Parameters:
properties- The properties to check.- Returns:
trueif this property holder has all the given properties,falseotherwise.
-
snapshot
Creates a new snapshot of this property container.- Returns:
- A new snapshot of this property container.
-
forType
Creates a new property container for the given structure type.- Parameters:
structureType- The structure type to create the property container for.- Returns:
- A new property container for the given structure type.
-
forProperties
Creates a new property container for the given properties.This method is intended for testing purposes only.
For production code, use
forType(StructureType)instead.- Parameters:
properties- The properties to create the property container for.- Returns:
- A new property container for the given properties.
-
iterator
Description copied from interface:IPropertyContainerConstReturns a read-only iterator over the properties in this container.Any properties that are either unmapped or of the wrong type are excluded.
- Specified by:
iteratorin interfaceIPropertyContainerConst- Specified by:
iteratorin interfaceIterable<PropertyValuePair<?>>- Returns:
- A read-only iterator over the properties in this container.
-
spliterator
Description copied from interface:IPropertyContainerConstReturns a read-only spliterator over the properties in this container.Any properties that are either unmapped or of the wrong type are excluded.
- Specified by:
spliteratorin interfaceIPropertyContainerConst- Specified by:
spliteratorin interfaceIterable<PropertyValuePair<?>>- Returns:
- A read-only spliterator over the properties in this container.
-
of
Creates a newPropertyContainerfrom the given properties.- Parameters:
properties- A group of interleaved property-value pairs.The even indices must be non-null
Propertys.The odd indices are the (nullable) values for the properties.
- Returns:
- A new
PropertyContainerwith the given properties. - Throws:
IllegalArgumentException- If the properties are not provided in pairs of 2.If an object at an even index is not a
Property.NullPointerException- If a property isnull.ClassCastException- If the value of a property cannot be cast to the type of the preceding property usingProperty.cast(Object).
-
of
Type-safe version ofof(Object...)for 1 property. -
of
public static <A,B> PropertyContainer of(Property<A> property0, @Nullable A value0, Property<B> property1, @Nullable B value1) Type-safe version ofof(Object...)for 2 properties. -
of
public static <A,B, PropertyContainer ofC> (Property<A> property0, @Nullable A value0, Property<B> property1, @Nullable B value1, Property<C> property2, @Nullable C value2) Type-safe version ofof(Object...)for 3 properties. -
of
public static <A,B, PropertyContainer ofC, D> (Property<A> property0, @Nullable A value0, Property<B> property1, @Nullable B value1, Property<C> property2, @Nullable C value2, Property<D> property3, @Nullable D value3) Type-safe version ofof(Object...)for 4 properties. -
of
public static <A,B, PropertyContainer ofC, D, E> (Property<A> property0, @Nullable A value0, Property<B> property1, @Nullable B value1, Property<C> property2, @Nullable C value2, Property<D> property3, @Nullable D value3, Property<E> property4, @Nullable E value4) Type-safe version ofof(Object...)for 5 properties. -
addAll
Adds all properties from the given property container to this property container.Existing properties will be overwritten.
- Parameters:
propertyContainer- The property container to add the properties from.
-
toString
-
equals
-
hashCode
public int hashCode()
-