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 class
SMFMetadataValue.Builder
Builds instances of typeSMFMetadataValue
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFMetadataValue.Builder
builder()
Creates a builder forSMFMetadataValue
.static SMFMetadataValue
copyOf(SMFMetadataValueType instance)
Creates an immutable copy of aSMFMetadataValueType
value.byte[]
data()
boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFMetadataValue
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:schemaId
,data
.static SMFMetadataValue
of(SMFSchemaIdentifier schemaId, byte[] data)
Construct a new immutableSMFMetadataValue
instance.SMFSchemaIdentifier
schemaId()
java.lang.String
toString()
Prints the immutable valueSMFMetadataValue
with attribute values.SMFMetadataValue
withData(byte... elements)
Copy the current immutable object with elements that replace the content ofdata
.SMFMetadataValue
withSchemaId(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaId
attribute.
-
-
-
Method Detail
-
schemaId
public SMFSchemaIdentifier schemaId()
- Specified by:
schemaId
in interfaceSMFMetadataValueType
- Returns:
- The metadata schema
-
data
public byte[] data()
- Specified by:
data
in interfaceSMFMetadataValueType
- Returns:
- The raw metadata bytes
-
withSchemaId
public final SMFMetadataValue withSchemaId(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaId
attribute. 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
this
object
-
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
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFMetadataValue
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
instance
-
hashCode
public int hashCode()
Computes a hash code from attributes:schemaId
,data
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFMetadataValue
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFMetadataValue of(SMFSchemaIdentifier schemaId, byte[] data)
Construct a new immutableSMFMetadataValue
instance.- Parameters:
schemaId
- The value for theschemaId
attributedata
- The value for thedata
attribute- Returns:
- An immutable SMFMetadataValue instance
-
copyOf
public static SMFMetadataValue copyOf(SMFMetadataValueType instance)
Creates an immutable copy of aSMFMetadataValueType
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 SMFMetadataValue instance
-
builder
public static SMFMetadataValue.Builder builder()
Creates a builder forSMFMetadataValue
.SMFMetadataValue.builder() .setSchemaId(com.io7m.smfj.core.SMFSchemaIdentifier) // required
schemaId
.setData(byte) // requireddata
.build();- Returns:
- A new SMFMetadataValue builder
-
-