Class SimpleMetadata

  • All Implemented Interfaces:
    Metadata

    public final class SimpleMetadata
    extends java.lang.Object
    implements Metadata
    An immutable metadata value holder backed by a map.
    Author:
    Carl Harris
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SimpleMetadata.Builder builder()
      Gets a builder that builds a new instance.
      static Metadata empty()
      Gets an instance that is empty.
      boolean equals​(java.lang.Object obj)  
      <T> T get​(java.lang.String name, java.lang.Class<? extends T> type)
      Gets a metadata property value.
      int hashCode()  
      boolean isEmpty()
      Tests whether this metadata object has any properties.
      java.util.Set<java.lang.String> names()
      Gets the names of the properties in this metadata collection.
      java.util.Map<java.lang.String,​java.lang.Object> toMap()
      Gets the contents of this metadata collection as a map.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • empty

        public static Metadata empty()
        Gets an instance that is empty.
        Returns:
        empty instance
      • builder

        public static SimpleMetadata.Builder builder()
        Gets a builder that builds a new instance.
        Returns:
        builder
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Metadata
        Tests whether this metadata object has any properties.
        Specified by:
        isEmpty in interface Metadata
        Returns:
        true if this metadata object has no properties
      • names

        public java.util.Set<java.lang.String> names()
        Description copied from interface: Metadata
        Gets the names of the properties in this metadata collection.
        Specified by:
        names in interface Metadata
        Returns:
        set of names
      • toMap

        public java.util.Map<java.lang.String,​java.lang.Object> toMap()
        Description copied from interface: Metadata
        Gets the contents of this metadata collection as a map.
        Specified by:
        toMap in interface Metadata
        Returns:
        map representation of this metadata; subsequent changes to the returned map will have no effect on this metadata collection
      • get

        public <T> T get​(java.lang.String name,
                         java.lang.Class<? extends T> type)
        Description copied from interface: Metadata
        Gets a metadata property value.

        As a special case, when retrieving a numeric property value (any of the supported subtypes of Number, if the stored value is not directly assignable to the specified type, it will be coerced to the specified type using one of methods provided on the Number class for doing so.

        Specified by:
        get in interface Metadata
        Type Parameters:
        T - return type
        Parameters:
        name - name of the property to retrieve.
        type - property type; the underlying implementation will restrict property values to String, Boolean, Integer, Long, Double
        Returns:
        property value or null if there is no property with the given name
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object