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)
.boolean
hasAttachment
(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.void
setAttachment
(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, wait
Methods 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:AttachmentContainer
Retrieves an attachment identified by the given key previously set byAttachmentContainer.setAttachment(String, Object)
. If no attribute was set with the given key,null
is returned.- Specified by:
getAttachment
in interfaceAttachmentContainer
- Parameters:
key
- The name of the attachment- Returns:
- The value of the attachment, or
null
if no attachment with the given key exists
-
setAttachment
Description copied from interface:AttachmentContainer
Stores 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:
setAttachment
in interfaceAttachmentContainer
- Parameters:
key
- The name string identifying the given value in thisAttributeContainer
value
- The value to be stored, ornull
to delete an existing attachment
-
hasAttachment
Description copied from interface:AttachmentContainer
Determines whether an attachment identified by the given key exists.- Specified by:
hasAttachment
in interfaceAttachmentContainer
- Parameters:
key
- The name of the attachment- Returns:
true
if an attachment with the given key exists- See Also:
-
removeAttachment
Description copied from interface:AttachmentContainer
Removes an attachment identified by the given key and returns it.- Specified by:
removeAttachment
in interfaceAttachmentContainer
- Parameters:
key
- The name of the attachment- Returns:
- The value of the attachment, or
null
if no attachment with the given key existed
-