Package com.io7m.smfj.core
Class SMFAttribute
- java.lang.Object
-
- com.io7m.smfj.core.SMFAttribute
-
- All Implemented Interfaces:
SMFAttributeType
public final class SMFAttribute extends java.lang.Object implements SMFAttributeType
An attribute.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMFAttribute.Builder
Builds instances of typeSMFAttribute
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFAttribute.Builder
builder()
Creates a builder forSMFAttribute
.int
componentCount()
int
componentSizeBits()
int
componentSizeOctets()
SMFComponentType
componentType()
static SMFAttribute
copyOf(SMFAttributeType instance)
Creates an immutable copy of aSMFAttributeType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFAttribute
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:name
,componentType
,componentCount
,componentSizeBits
,componentSizeOctets
,sizeOctets
.SMFAttributeName
name()
static SMFAttribute
of(SMFAttributeName name, SMFComponentType componentType, int componentCount, int componentSizeBits)
Construct a new immutableSMFAttribute
instance.int
sizeOctets()
java.lang.String
toString()
Prints the immutable valueSMFAttribute
with attribute values.SMFAttribute
withComponentCount(int value)
Copy the current immutable object by setting a value for thecomponentCount
attribute.SMFAttribute
withComponentSizeBits(int value)
Copy the current immutable object by setting a value for thecomponentSizeBits
attribute.SMFAttribute
withComponentType(SMFComponentType value)
Copy the current immutable object by setting a value for thecomponentType
attribute.SMFAttribute
withName(SMFAttributeName value)
Copy the current immutable object by setting a value for thename
attribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.smfj.core.SMFAttributeType
checkPreconditions
-
-
-
-
Method Detail
-
name
public SMFAttributeName name()
- Specified by:
name
in interfaceSMFAttributeType
- Returns:
- The name of the attribute
-
componentType
public SMFComponentType componentType()
- Specified by:
componentType
in interfaceSMFAttributeType
- Returns:
- The kind of components that make up the attribute
-
componentCount
public int componentCount()
- Specified by:
componentCount
in interfaceSMFAttributeType
- Returns:
- The number of components in the attribute
-
componentSizeBits
public int componentSizeBits()
- Specified by:
componentSizeBits
in interfaceSMFAttributeType
- Returns:
- The size of a single component in bits
-
componentSizeOctets
public int componentSizeOctets()
- Specified by:
componentSizeOctets
in interfaceSMFAttributeType
- Returns:
- The size of a single component in octets
-
sizeOctets
public int sizeOctets()
- Specified by:
sizeOctets
in interfaceSMFAttributeType
- Returns:
- The size of the attribute in octets
-
withName
public final SMFAttribute withName(SMFAttributeName value)
Copy the current immutable object by setting a value for thename
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for name- Returns:
- A modified copy of the
this
object
-
withComponentType
public final SMFAttribute withComponentType(SMFComponentType value)
Copy the current immutable object by setting a value for thecomponentType
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for componentType- Returns:
- A modified copy of the
this
object
-
withComponentCount
public final SMFAttribute withComponentCount(int value)
Copy the current immutable object by setting a value for thecomponentCount
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for componentCount- Returns:
- A modified copy of the
this
object
-
withComponentSizeBits
public final SMFAttribute withComponentSizeBits(int value)
Copy the current immutable object by setting a value for thecomponentSizeBits
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for componentSizeBits- Returns:
- A modified copy of the
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFAttribute
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:name
,componentType
,componentCount
,componentSizeBits
,componentSizeOctets
,sizeOctets
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFAttribute
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFAttribute of(SMFAttributeName name, SMFComponentType componentType, int componentCount, int componentSizeBits)
Construct a new immutableSMFAttribute
instance.- Parameters:
name
- The value for thename
attributecomponentType
- The value for thecomponentType
attributecomponentCount
- The value for thecomponentCount
attributecomponentSizeBits
- The value for thecomponentSizeBits
attribute- Returns:
- An immutable SMFAttribute instance
-
copyOf
public static SMFAttribute copyOf(SMFAttributeType instance)
Creates an immutable copy of aSMFAttributeType
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 SMFAttribute instance
-
builder
public static SMFAttribute.Builder builder()
Creates a builder forSMFAttribute
.SMFAttribute.builder() .setName(com.io7m.smfj.core.SMFAttributeName) // required
name
.setComponentType(com.io7m.smfj.core.SMFComponentType) // requiredcomponentType
.setComponentCount(int) // requiredcomponentCount
.setComponentSizeBits(int) // requiredcomponentSizeBits
.build();- Returns:
- A new SMFAttribute builder
-
-