Class SMFMetadata

  • All Implemented Interfaces:
    SMFMetadataType

    public final class SMFMetadata
    extends java.lang.Object
    implements SMFMetadataType
    Parsed immutable metadata.
    • Method Detail

      • data

        public byte[] data()
        Specified by:
        data in interface SMFMetadataType
        Returns:
        The metadata
      • withSchema

        public final SMFMetadata withSchema​(SMFSchemaIdentifier value)
        Copy the current immutable object by setting a value for the schema attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for schema
        Returns:
        A modified copy of the this object
      • withData

        public final SMFMetadata withData​(byte... elements)
        Copy the current immutable object with elements that replace the content of data. The array is cloned before being saved as attribute values.
        Parameters:
        elements - The non-null elements for data
        Returns:
        A modified copy of this object
      • equals

        public boolean equals​(java.lang.Object another)
        This instance is equal to all instances of SMFMetadata that have equal attribute values.
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if this is equal to another instance
      • hashCode

        public int hashCode()
        Computes a hash code from attributes: schema, data.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashCode value
      • toString

        public java.lang.String toString()
        Prints the immutable value SMFMetadata with attribute values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the value
      • of

        public static SMFMetadata of​(SMFSchemaIdentifier schema,
                                     byte[] data)
        Construct a new immutable SMFMetadata instance.
        Parameters:
        schema - The value for the schema attribute
        data - The value for the data attribute
        Returns:
        An immutable SMFMetadata instance
      • copyOf

        public static SMFMetadata copyOf​(SMFMetadataType instance)
        Creates an immutable copy of a SMFMetadataType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
        Parameters:
        instance - The instance to copy
        Returns:
        A copied immutable SMFMetadata instance
      • builder

        public static SMFMetadata.Builder builder()
        Creates a builder for SMFMetadata.
         SMFMetadata.builder()
            .setSchema(com.io7m.smfj.core.SMFSchemaIdentifier) // required schema
            .setData(byte) // required data
            .build();
         
        Returns:
        A new SMFMetadata builder