Class DefaultAnnotations

  • All Implemented Interfaces:
    Annotations, SparseAnnotations

    public final class DefaultAnnotations
    extends Object
    implements SparseAnnotations
    Represents a set of simple annotations that can be used to add arbitrary attributes to various parts of the data model.
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • asMap

        public HashMap<String,​String> asMap()
        Returns the annotations as a map.
        Returns:
        a copy of the contents of the annotations as a map.
      • builder

        public static DefaultAnnotations.Builder builder()
        Creates a new annotations builder.
        Returns:
        new annotations builder
      • merge

        public static DefaultAnnotations merge​(DefaultAnnotations annotations,
                                               SparseAnnotations sparseAnnotations)
        Merges the specified base set of annotations and additional sparse annotations into new combined annotations. If the supplied sparse annotations are empty, the original base annotations are returned. Any keys tagged for removal in the sparse annotations will be omitted in the resulting merged annotations.
        Parameters:
        annotations - base annotations
        sparseAnnotations - additional sparse annotations
        Returns:
        combined annotations or the original base annotations if there are not additional annotations
      • union

        public static SparseAnnotations union​(SparseAnnotations annotations,
                                              SparseAnnotations sparseAnnotations)
        Creates the union of two given SparseAnnotations. Unlike the merge(DefaultAnnotations, SparseAnnotations) method, result will be SparseAnnotations instead of Annotations. A key tagged for removal will remain in the output SparseAnnotations, if the counterpart of the input does not contain the same key.
        Parameters:
        annotations - base annotations
        sparseAnnotations - additional sparse annotations
        Returns:
        combined annotations or the original base annotations if there are not additional annotations
      • keys

        public Set<String> keys()
        Description copied from interface: SparseAnnotations
        Returns the set of keys for available annotations.

        Note that this set includes keys for any attributes tagged for removal.

        Specified by:
        keys in interface Annotations
        Specified by:
        keys in interface SparseAnnotations
        Returns:
        annotation keys
      • value

        public String value​(String key)
        Description copied from interface: Annotations
        Returns the value of the specified annotation.
        Specified by:
        value in interface Annotations
        Parameters:
        key - annotation key
        Returns:
        annotation value
      • isRemoved

        public boolean isRemoved​(String key)
        Description copied from interface: SparseAnnotations
        Indicates whether the specified key has been tagged as removed. This is used for merging sparse annotation sets.
        Specified by:
        isRemoved in interface SparseAnnotations
        Parameters:
        key - annotation key
        Returns:
        true if the previous annotation has been tagged for removal