Class SimpleAttachmentContainer

java.lang.Object
org.omegazero.common.util.SimpleAttachmentContainer
All Implemented Interfaces:
AttachmentContainer

public class SimpleAttachmentContainer extends Object implements 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 Details

    • attachments

      protected Map<String,Object> attachments
      Map containing the values of this SimpleAttachmentContainer.
  • Constructor Details

    • SimpleAttachmentContainer

      public SimpleAttachmentContainer()
  • Method Details

    • getAttachment

      public Object getAttachment(String key)
      Description copied from interface: AttachmentContainer
      Retrieves an attachment identified by the given key previously set by AttachmentContainer.setAttachment(String, Object). If no attribute was set with the given key, null is returned.
      Specified by:
      getAttachment in interface AttachmentContainer
      Parameters:
      key - The name of the attachment
      Returns:
      The value of the attachment, or null if no attachment with the given key exists
    • setAttachment

      public void setAttachment(String key, Object value)
      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 interface AttachmentContainer
      Parameters:
      key - The name string identifying the given value in this AttributeContainer
      value - The value to be stored, or null to delete an existing attachment
    • hasAttachment

      public boolean hasAttachment(String key)
      Description copied from interface: AttachmentContainer
      Determines whether an attachment identified by the given key exists.
      Specified by:
      hasAttachment in interface AttachmentContainer
      Parameters:
      key - The name of the attachment
      Returns:
      true if an attachment with the given key exists
      See Also:
    • removeAttachment

      public Object removeAttachment(String key)
      Description copied from interface: AttachmentContainer
      Removes an attachment identified by the given key and returns it.
      Specified by:
      removeAttachment in interface AttachmentContainer
      Parameters:
      key - The name of the attachment
      Returns:
      The value of the attachment, or null if no attachment with the given key existed