-
Notifications
You must be signed in to change notification settings - Fork 24
Adding, getting and removing attributes
An AttributeContainer (API docs) is a store for attributes. An Entity is an AttributeContainer although the container is useful on its own. JALSE offers a default implementation of AttributeContainer, DefaultAttributeContainer, which can also be used to create your own Entity implementation.
AttributeContainer container = new DefaultAttributeContainer();AttributeContainer uses a attribute name with an AttributeType or NamedAttributeType for a unique key (see Creating an AttributeType). When attributes are added, changed or move they trigger listener events (see Creating an AttributeListener).
Adding an attribute assigns a value to the name and type key. This will replace the previously associated value.
String previous = container.addAttribute("username", Attributes.STRING_TYPE, "Ellzord");or
Optional<String> optPrevious = container.addOptAttribute("username", Attributes.STRING_TYPE, "Ellzord");There are NamedAttributeType equivalents: container.addAttribute(NamedAttributeType, Object) and container.addOptAttribute(NamedAttributeType, Object).
Check out the Example projects and Code snippets!
Getting Started
- Getting the latest release
- Building from source
- Example projects
- Code snippets
- How to contribute
- Have bugs or questions?
How To Use
- JALSE
- Entities
- Attributes
- Actions
- Tags
Misc