public class DefaultAttributeContainer extends java.lang.Object implements AttributeContainer
AttributeContainer
.AttributeEvent
. Attribute updates will trigger these events using
AttributeListener
.Modifier and Type | Class and Description |
---|---|
static class |
DefaultAttributeContainer.Builder
Chaining builder for DefaultAttributeContainer.
|
Constructor and Description |
---|
DefaultAttributeContainer()
Creates a new instance of DefaultAttributeContainer with no delegate container (self).
|
DefaultAttributeContainer(AttributeContainer delegateContainer)
Creates a new instance of DefaultAttributeContainer with a delegate container.
|
Modifier and Type | Method and Description |
---|---|
<T> boolean |
addAttributeListener(NamedAttributeType<T> namedType,
AttributeListener<T> listener)
Adds an attribute listener for the supplied named attribute type.
|
boolean |
equals(java.lang.Object obj) |
<T> void |
fireAttributeChanged(NamedAttributeType<T> namedType)
Manually fires an attribute change for the supplied attribute type.
|
<T> T |
getAttribute(NamedAttributeType<T> namedType)
Gets the attribute matching the supplied type.
|
int |
getAttributeCount()
Gets the number of total attributes within the container.
|
<T> java.util.Set<? extends AttributeListener<T>> |
getAttributeListeners(NamedAttributeType<T> namedType)
Gets all attribute listeners associated to the supplied named attribute type.
|
java.util.Set<NamedAttributeType<?>> |
getAttributeListenerTypes()
Gets all of the named attribute types with listeners bound.
|
java.util.Set<NamedAttributeType<?>> |
getAttributeTypes()
Gets all of the named attribute types with attributes.
|
AttributeContainer |
getDelegateContainer()
Gets the delegate container.
|
int |
hashCode() |
<T> T |
removeAttribute(NamedAttributeType<T> namedType)
Removes the attribute matching the supplied type.
|
<T> boolean |
removeAttributeListener(NamedAttributeType<T> namedType,
AttributeListener<T> listener)
Removes an attribute listener assigned to the supplied attribute type.
|
void |
removeAttributeListeners()
Removes all listeners.
|
<T> void |
removeAttributeListeners(NamedAttributeType<T> namedType)
Removes all listeners for the supplied attribute types.
|
void |
removeAttributes()
Removes all attributes within the container (firing removal events).
|
<T> T |
setAttribute(NamedAttributeType<T> namedType,
T attr)
Adds the supplied attribute to the collection.
|
java.util.stream.Stream<?> |
streamAttributes()
Streams all of the attributes within the container.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, addAllAttributeListeners, addAllAttributes, addAttributeListener, fireAttributeChanged, getAttribute, getAttributeListenerNames, getAttributeListeners, getAttributeListenerTypes, getAttributeNames, getAttributes, getAttributeTypes, getOptAttribute, getOptAttribute, hasAttribute, hasAttribute, hasAttributeListener, hasAttributeListener, hasAttributeListeners, hasAttributeListeners, hasAttributes, removeAttribute, removeAttributeListener, removeAttributeListeners, removeOptAttribute, removeOptAttribute, setAttribute, setOptAttribute, setOptAttribute
public DefaultAttributeContainer()
public DefaultAttributeContainer(AttributeContainer delegateContainer)
delegateContainer
- Delegate AttributeContainer for events.public <T> boolean addAttributeListener(NamedAttributeType<T> namedType, AttributeListener<T> listener)
AttributeContainer
addAttributeListener
in interface AttributeContainer
namedType
- Named attribute type.listener
- Listener to add.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public <T> void fireAttributeChanged(NamedAttributeType<T> namedType)
AttributeContainer
fireAttributeChanged
in interface AttributeContainer
namedType
- Named attribute type name.public <T> T getAttribute(NamedAttributeType<T> namedType)
AttributeContainer
getAttribute
in interface AttributeContainer
namedType
- Named attribute type to check for.public int getAttributeCount()
AttributeContainer
getAttributeCount
in interface AttributeContainer
public <T> java.util.Set<? extends AttributeListener<T>> getAttributeListeners(NamedAttributeType<T> namedType)
AttributeContainer
getAttributeListeners
in interface AttributeContainer
namedType
- Named attribute type to check for.public java.util.Set<NamedAttributeType<?>> getAttributeListenerTypes()
AttributeContainer
getAttributeListenerTypes
in interface AttributeContainer
public java.util.Set<NamedAttributeType<?>> getAttributeTypes()
AttributeContainer
getAttributeTypes
in interface AttributeContainer
public AttributeContainer getDelegateContainer()
public int hashCode()
hashCode
in class java.lang.Object
public <T> T removeAttribute(NamedAttributeType<T> namedType)
AttributeContainer
removeAttribute
in interface AttributeContainer
namedType
- Named attribute type to remove.public <T> boolean removeAttributeListener(NamedAttributeType<T> namedType, AttributeListener<T> listener)
AttributeContainer
removeAttributeListener
in interface AttributeContainer
namedType
- Named attribute type.listener
- Listener to remove.public void removeAttributeListeners()
AttributeContainer
removeAttributeListeners
in interface AttributeContainer
public <T> void removeAttributeListeners(NamedAttributeType<T> namedType)
AttributeContainer
removeAttributeListeners
in interface AttributeContainer
namedType
- Named attribute type.public void removeAttributes()
AttributeContainer
removeAttributes
in interface AttributeContainer
public <T> T setAttribute(NamedAttributeType<T> namedType, T attr)
AttributeContainer
setAttribute
in interface AttributeContainer
namedType
- Named attribute type.attr
- Attribute to add.public java.util.stream.Stream<?> streamAttributes()
AttributeContainer
streamAttributes
in interface AttributeContainer
public java.lang.String toString()
toString
in class java.lang.Object