Class AttributeSet
- java.lang.Object
-
- org.infinispan.commons.configuration.attributes.AttributeSet
-
- All Implemented Interfaces:
AttributeListener<Object>
,Matchable<AttributeSet>
,Updatable<AttributeSet>
public class AttributeSet extends Object implements AttributeListener<Object>, Matchable<AttributeSet>, Updatable<AttributeSet>
AttributeSet is a container forAttribute
s. It is constructed by passing in a list ofAttributeDefinition
s. AttributeSets are initially unprotected, which means that the contained attributes can be modified. If theprotect()
method is invoked then only attributes which are notAttributeDefinition.isImmutable()
can be modified from then on.- Since:
- 7.2
- Author:
- Tristan Tarrant
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeSet
EMPTY
-
Constructor Summary
Constructors Constructor Description AttributeSet(Class<?> klass, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(Class<?> klass, AttributeSet attributeSet, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(String name, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(String name, AttributeSet attributeSet, AttributeDefinition<?>[] attributeDefinitions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Attribute<T>
attribute(Enum<?> name)
Returns the named attribute<T> Attribute<T>
attribute(String name)
Returns the named attribute<T> Attribute<T>
attribute(AttributeDefinition<T> def)
Returns the attribute identified by the suppliedAttributeDefinition
void
attributeChanged(Attribute<Object> attribute, Object oldValue)
Collection<Attribute<?>>
attributes()
AttributeSet
checkProtection()
boolean
contains(String name)
Returns whether this attribute set contains the specified named attribute<T> boolean
contains(AttributeDefinition<T> def)
Returns whether this set contains the specified attribute definitionboolean
equals(Object obj)
Class<?>
getKlass()
String
getName()
int
hashCode()
boolean
isEmpty()
boolean
isModified()
Returns whether any attributes in this set have been modifiedboolean
isProtected()
Returns whether this attribute set is protectedboolean
matches(AttributeSet other)
AttributeSet
protect()
Returns a new ValueSet where immutableAttribute
s are write-protectedvoid
read(AttributeSet other)
Copies all attribute from another AttributeSetvoid
reset()
String
toString()
String
toString(String name)
void
update(AttributeSet other)
Updates the mutable part of this instance with the values of the other instancevoid
validate()
Validates theAttribute
values.void
validateUpdate(AttributeSet other)
Verifies that updating the mutable part of this instance with the values of the other instance is possiblevoid
write(ConfigurationWriter writer)
Writes the attributes of this attributeset as part of the current elementvoid
write(ConfigurationWriter writer, Enum<?> name)
Writes this attributeset to the specified ConfigurationWriter as an elementvoid
write(ConfigurationWriter writer, String name)
Writes this attributeset to the specified ConfigurationWriter as an elementvoid
write(ConfigurationWriter writer, String persistentName, AttributeDefinition<?>... defs)
Writes the specified attributes in this attributeset to the specified ConfigurationWriter as an elementvoid
write(ConfigurationWriter writer, AttributeDefinition<?> def)
Writer a single attribute to the specifiedConfigurationWriter
using the attribute's xmlNamevoid
write(ConfigurationWriter writer, AttributeDefinition<?> def, Enum<?> name)
Writer a single attribute to the specifiedConfigurationWriter
using the supplied namevoid
write(ConfigurationWriter writer, AttributeDefinition<?> def, String name)
Writer a single attribute to the specifiedConfigurationWriter
using the supplied name
-
-
-
Field Detail
-
EMPTY
public static final AttributeSet EMPTY
-
-
Constructor Detail
-
AttributeSet
public AttributeSet(Class<?> klass, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(String name, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(Class<?> klass, AttributeSet attributeSet, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(String name, AttributeSet attributeSet, AttributeDefinition<?>[] attributeDefinitions)
-
-
Method Detail
-
getKlass
public Class<?> getKlass()
-
getName
public String getName()
-
contains
public boolean contains(String name)
Returns whether this attribute set contains the specified named attribute- Parameters:
name
- the name of the attribute
-
contains
public <T> boolean contains(AttributeDefinition<T> def)
Returns whether this set contains the specified attribute definition- Parameters:
def
- theAttributeDefinition
-
attribute
public <T> Attribute<T> attribute(String name)
Returns the named attribute- Parameters:
name
- the name of the attribute to return- Returns:
- the attribute
-
attribute
public <T> Attribute<T> attribute(Enum<?> name)
Returns the named attribute- Parameters:
name
- the name of the attribute to return- Returns:
- the attribute
-
attribute
public <T> Attribute<T> attribute(AttributeDefinition<T> def)
Returns the attribute identified by the suppliedAttributeDefinition
- Parameters:
def
- the attribute definition- Returns:
- the attribute
-
read
public void read(AttributeSet other)
Copies all attribute from another AttributeSet- Parameters:
other
- the source AttributeSet
-
protect
public AttributeSet protect()
Returns a new ValueSet where immutableAttribute
s are write-protected- Returns:
-
isModified
public boolean isModified()
Returns whether any attributes in this set have been modified
-
isProtected
public boolean isProtected()
Returns whether this attribute set is protected
-
write
public void write(ConfigurationWriter writer, AttributeDefinition<?> def)
Writer a single attribute to the specifiedConfigurationWriter
using the attribute's xmlName- Parameters:
writer
- the writerdef
- the Attribute definition
-
write
public void write(ConfigurationWriter writer, AttributeDefinition<?> def, Enum<?> name)
Writer a single attribute to the specifiedConfigurationWriter
using the supplied name- Parameters:
writer
- the writerdef
- the Attribute definitionname
- the XML tag name for the attribute
-
write
public void write(ConfigurationWriter writer, AttributeDefinition<?> def, String name)
Writer a single attribute to the specifiedConfigurationWriter
using the supplied name- Parameters:
writer
- the writerdef
- the Attribute definitionname
- the XML tag name for the attribute
-
write
public void write(ConfigurationWriter writer, String name)
Writes this attributeset to the specified ConfigurationWriter as an element- Parameters:
writer
-
-
write
public void write(ConfigurationWriter writer, Enum<?> name)
Writes this attributeset to the specified ConfigurationWriter as an element- Parameters:
writer
-
-
write
public void write(ConfigurationWriter writer, String persistentName, AttributeDefinition<?>... defs)
Writes the specified attributes in this attributeset to the specified ConfigurationWriter as an element- Parameters:
writer
-
-
write
public void write(ConfigurationWriter writer)
Writes the attributes of this attributeset as part of the current element- Parameters:
writer
-
-
validate
public void validate()
Validates theAttribute
values.
-
matches
public boolean matches(AttributeSet other)
- Specified by:
matches
in interfaceMatchable<AttributeSet>
-
update
public void update(AttributeSet other)
Description copied from interface:Updatable
Updates the mutable part of this instance with the values of the other instance- Specified by:
update
in interfaceUpdatable<AttributeSet>
-
validateUpdate
public void validateUpdate(AttributeSet other)
Description copied from interface:Updatable
Verifies that updating the mutable part of this instance with the values of the other instance is possible- Specified by:
validateUpdate
in interfaceUpdatable<AttributeSet>
-
checkProtection
public AttributeSet checkProtection()
-
reset
public void reset()
-
attributeChanged
public void attributeChanged(Attribute<Object> attribute, Object oldValue)
- Specified by:
attributeChanged
in interfaceAttributeListener<Object>
-
attributes
public Collection<Attribute<?>> attributes()
-
isEmpty
public boolean isEmpty()
-
-