Class ComplexAttributeImpl
- Object
-
- PropertyImpl
-
- AttributeImpl
-
- ComplexAttributeImpl
-
- All Implemented Interfaces:
Attribute
,ComplexAttribute
,Property
- Direct Known Subclasses:
FeatureImpl
public class ComplexAttributeImpl extends AttributeImpl implements ComplexAttribute
-
-
Field Summary
-
Fields inherited from class AttributeImpl
id
-
Fields inherited from class PropertyImpl
descriptor, value
-
-
Constructor Summary
Constructors Constructor Description ComplexAttributeImpl(Collection<Property> properties, AttributeDescriptor descriptor, Identifier id)
ComplexAttributeImpl(Collection<Property> properties, ComplexType type, Identifier id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(Property value)
Appends a property to this attribute's property list without incurring in unnecessary object allocation such as safe-copying the values list as insetValue(Collection)
Optional<Property>
find(Predicate<? super Property> predicate)
Stream<Property>
findAll(Predicate<? super Property> predicate)
Optional<Property>
findLast(Name name)
Collection<Property>
getProperties()
Complete collection of properties.Collection<Property>
getProperties(String name)
Returns a subset of the properties of the complex attribute which match the specified name.Collection<Property>
getProperties(Name name)
Returns a subset of the properties of the complex attribute which match the specified name.Property
getProperty(String name)
Returns single property of the complex attribute which matches the specified name.Property
getProperty(Name name)
Returns single property of the complex attribute which matches the specified name.ComplexType
getType()
The type of the property.Collection<? extends Property>
getValue()
The value or content of the property.protected List<Property>
properties()
Internal helper method for getting at the properties without wrapping in unmodifiable collection.void
setValue(Object newValue)
Override of setValue to convert the newValue to specified type if need be.void
setValue(Collection<Property> newValue)
Sets the contained properties of the complex attribute.-
Methods inherited from class AttributeImpl
equals, getDescriptor, getIdentifier, hashCode, parse, toString, validate
-
Methods inherited from class PropertyImpl
getName, getUserData, getUserData, isNillable
-
Methods inherited from interface Attribute
getDescriptor, getIdentifier
-
Methods inherited from interface ComplexAttribute
validate
-
Methods inherited from interface Property
getName, getUserData, hasUserData, isNillable
-
-
-
-
Constructor Detail
-
ComplexAttributeImpl
public ComplexAttributeImpl(Collection<Property> properties, AttributeDescriptor descriptor, Identifier id)
-
ComplexAttributeImpl
public ComplexAttributeImpl(Collection<Property> properties, ComplexType type, Identifier id)
-
-
Method Detail
-
getType
public ComplexType getType()
Description copied from interface:Property
The type of the property.The type contains information about the value or content of the property such as its java class.
This value is also available via
getDescriptor().getType()
.- Specified by:
getType
in interfaceAttribute
- Specified by:
getType
in interfaceComplexAttribute
- Specified by:
getType
in interfaceProperty
- Overrides:
getType
in classAttributeImpl
- Returns:
- The property type.
- See Also:
Property.getType()
-
getValue
public Collection<? extends Property> getValue()
Description copied from interface:Property
The value or content of the property.The class of this object is defined by
getType().getBinding()
.This value may be
null
. In this casegetDescriptor().isNillable()
would betrue
.- Specified by:
getValue
in interfaceComplexAttribute
- Specified by:
getValue
in interfaceProperty
- Overrides:
getValue
in classPropertyImpl
- Returns:
- The value of the property.
-
getProperties
public Collection<Property> getProperties()
Description copied from interface:ComplexAttribute
Complete collection of properties.This method is a convenience method for calling (Collection
) getValue(). - Specified by:
getProperties
in interfaceComplexAttribute
- Returns:
- The complete collection of properties.
-
properties
protected List<Property> properties()
Internal helper method for getting at the properties without wrapping in unmodifiable collection.
-
getProperties
public Collection<Property> getProperties(Name name)
Description copied from interface:ComplexAttribute
Returns a subset of the properties of the complex attribute which match the specified name.The name parameter is matched against each contained
Property.getName()
, those that are equal are returned.- Specified by:
getProperties
in interfaceComplexAttribute
- Parameters:
name
- The name of the properties to return.- Returns:
- The collection of properties which match the specified name, or an empty collection if no such properties match.
-
findLast
public Optional<Property> findLast(Name name)
- Returns:
- the first property in
getProperties()
reverse order whosename
equals the givenname
-
findAll
public Stream<Property> findAll(Predicate<? super Property> predicate)
- Returns:
- all properties that match the provided predicate, may be empty, never
null
-
find
public Optional<Property> find(Predicate<? super Property> predicate)
- Returns:
- the first property that matches the provided predicate, or
Optional.empty()
-
getProperties
public Collection<Property> getProperties(String name)
Description copied from interface:ComplexAttribute
Returns a subset of the properties of the complex attribute which match the specified name.This method is a convenience for
ComplexAttribute.getProperties(Name)
in whichName.getNamespaceURI()
isnull
.Note: Special care should be taken when using this method in the case that two properties with the same local name but different namespace uri exist. For this reason using
ComplexAttribute.getProperties(Name)
is safer.- Specified by:
getProperties
in interfaceComplexAttribute
- Parameters:
name
- The local name of the properties to return.- Returns:
- The collection of properties which match the specified name, or an empty collection if no such properties match.
- See Also:
ComplexAttribute.getProperties(Name)
-
getProperty
public Property getProperty(Name name)
Description copied from interface:ComplexAttribute
Returns single property of the complex attribute which matches the specified name.Note: This method is a convenience and care should be taken when calling it if more then a single property matches name. In such a case the first encountered property in which
Property.getName()
is equal to name is returned, and no order is guaranteed.This method is a safe convenience for:
getProperties(name).iterator().next()
.In the event that no property matches the specified name
null
is returned.- Specified by:
getProperty
in interfaceComplexAttribute
- Parameters:
name
- The name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
getProperty
public Property getProperty(String name)
Description copied from interface:ComplexAttribute
Returns single property of the complex attribute which matches the specified name.This method is a convenience for
ComplexAttribute.getProperty(Name)
in whichName.getNamespaceURI()
isnull
.Note: This method is a convenience and care should be taken when calling it if more then a single property matches name. In such a case the first encountered property in which
Property.getName()
is matches name is returned, and no order is guaranteed.Note: Special care should be taken when using this method in the case that two properties with the same local name but different namespace uri exist. For this reason using
ComplexAttribute.getProperties(Name)
is safer.- Specified by:
getProperty
in interfaceComplexAttribute
- Parameters:
name
- The local name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
setValue
public void setValue(Object newValue) throws IllegalArgumentException, IllegalStateException
Description copied from class:AttributeImpl
Override of setValue to convert the newValue to specified type if need be.- Specified by:
setValue
in interfaceProperty
- Overrides:
setValue
in classAttributeImpl
- Parameters:
newValue
- The new value of the property.- Throws:
IllegalArgumentException
IllegalStateException
-
setValue
public void setValue(Collection<Property> newValue)
Description copied from interface:ComplexAttribute
Sets the contained properties of the complex attribute.The values should match the structure defined by
getDescriptor()
.- Specified by:
setValue
in interfaceComplexAttribute
-
addValue
public void addValue(Property value)
Appends a property to this attribute's property list without incurring in unnecessary object allocation such as safe-copying the values list as insetValue(Collection)
-
-