Package com.io7m.smfj.core
Class SMFMetadataValue
- java.lang.Object
-
- com.io7m.smfj.core.SMFMetadataValue
-
- All Implemented Interfaces:
SMFMetadataValueType
public final class SMFMetadataValue extends java.lang.Object implements SMFMetadataValueType
A parsed metadata value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSMFMetadataValue.BuilderBuilds instances of typeSMFMetadataValue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFMetadataValue.Builderbuilder()Creates a builder forSMFMetadataValue.static SMFMetadataValuecopyOf(SMFMetadataValueType instance)Creates an immutable copy of aSMFMetadataValueTypevalue.byte[]data()booleanequals(java.lang.Object another)This instance is equal to all instances ofSMFMetadataValuethat have equal attribute values.inthashCode()Computes a hash code from attributes:schemaId,data.static SMFMetadataValueof(SMFSchemaIdentifier schemaId, byte[] data)Construct a new immutableSMFMetadataValueinstance.SMFSchemaIdentifierschemaId()java.lang.StringtoString()Prints the immutable valueSMFMetadataValuewith attribute values.SMFMetadataValuewithData(byte... elements)Copy the current immutable object with elements that replace the content ofdata.SMFMetadataValuewithSchemaId(SMFSchemaIdentifier value)Copy the current immutable object by setting a value for theschemaIdattribute.
-
-
-
Method Detail
-
schemaId
public SMFSchemaIdentifier schemaId()
- Specified by:
schemaIdin interfaceSMFMetadataValueType- Returns:
- The metadata schema
-
data
public byte[] data()
- Specified by:
datain interfaceSMFMetadataValueType- Returns:
- The raw metadata bytes
-
withSchemaId
public final SMFMetadataValue withSchemaId(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaIdattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for schemaId- Returns:
- A modified copy of the
thisobject
-
withData
public final SMFMetadataValue withData(byte... elements)
Copy the current immutable object with elements that replace the content ofdata. The array is cloned before being saved as attribute values.- Parameters:
elements- The non-null elements for data- Returns:
- A modified copy of
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFMetadataValuethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:schemaId,data.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFMetadataValuewith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static SMFMetadataValue of(SMFSchemaIdentifier schemaId, byte[] data)
Construct a new immutableSMFMetadataValueinstance.- Parameters:
schemaId- The value for theschemaIdattributedata- The value for thedataattribute- Returns:
- An immutable SMFMetadataValue instance
-
copyOf
public static SMFMetadataValue copyOf(SMFMetadataValueType instance)
Creates an immutable copy of aSMFMetadataValueTypevalue. 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 SMFMetadataValue instance
-
builder
public static SMFMetadataValue.Builder builder()
Creates a builder forSMFMetadataValue.SMFMetadataValue.builder() .setSchemaId(com.io7m.smfj.core.SMFSchemaIdentifier) // requiredschemaId.setData(byte) // requireddata.build();- Returns:
- A new SMFMetadataValue builder
-
-