Class Attachment<T>

  • Type Parameters:
    T - The type of attachment.

    public final class Attachment<T>
    extends Object
    Class used to define dynamic typed attachments on AttachmentHolder instances. Storing attachment values in AttachmentHolder has the advantage of the Attachment value being typed when compared to Map storage:
    • Constructor Detail

      • Attachment

        public Attachment​(String name,
                          T defaultValue)
        Construct a new attachment with the specified name and default value.
        Parameters:
        name - Attachment name.
        defaultValue - Attachment default value, which will be used, if it is not set.
    • Method Detail

      • set

        public T set​(AttachmentHolder attachmentHolder,
                     T value)
        Set attachment value, stored on the AttachmentHolder. If a value already exists, it will be replaced.
        Parameters:
        attachmentHolder - AttachmentHolder.
        value - attachment value to set.
        Returns:
        The former value or null if there was previously no value.