Package org.omegazero.common.util
Class SimpleAttachmentContainer
java.lang.Object
org.omegazero.common.util.SimpleAttachmentContainer
- All Implemented Interfaces:
AttachmentContainer
An
AttachmentContainer implementation using a HashMap, which may be used as a superclass for more specific objects.
This class is not thread-safe.
- Since:
- 2.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap containing the values of thisSimpleAttachmentContainer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttachment(String key) Retrieves an attachment identified by the given key previously set byAttachmentContainer.setAttachment(String, Object).booleanhasAttachment(String key) Determines whether an attachment identified by the given key exists.removeAttachment(String key) Removes an attachment identified by the given key and returns it.voidsetAttachment(String key, Object value) Stores an object identified by the given key.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.omegazero.common.util.AttachmentContainer
requireAttachment
-
Field Details
-
attachments
Map containing the values of thisSimpleAttachmentContainer.
-
-
Constructor Details
-
SimpleAttachmentContainer
public SimpleAttachmentContainer()
-
-
Method Details
-
getAttachment
Description copied from interface:AttachmentContainerRetrieves an attachment identified by the given key previously set byAttachmentContainer.setAttachment(String, Object). If no attribute was set with the given key,nullis returned.- Specified by:
getAttachmentin interfaceAttachmentContainer- Parameters:
key- The name of the attachment- Returns:
- The value of the attachment, or
nullif no attachment with the given key exists
-
setAttachment
Description copied from interface:AttachmentContainerStores an object identified by the given key.Values stored here likely have no meaning in the used application and are purely intended to store metadata used by the application.
- Specified by:
setAttachmentin interfaceAttachmentContainer- Parameters:
key- The name string identifying the given value in thisAttributeContainervalue- The value to be stored, ornullto delete an existing attachment
-
hasAttachment
Description copied from interface:AttachmentContainerDetermines whether an attachment identified by the given key exists.- Specified by:
hasAttachmentin interfaceAttachmentContainer- Parameters:
key- The name of the attachment- Returns:
trueif an attachment with the given key exists- See Also:
-
removeAttachment
Description copied from interface:AttachmentContainerRemoves an attachment identified by the given key and returns it.- Specified by:
removeAttachmentin interfaceAttachmentContainer- Parameters:
key- The name of the attachment- Returns:
- The value of the attachment, or
nullif no attachment with the given key existed
-