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 classSMFAttribute.BuilderBuilds instances of typeSMFAttribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFAttribute.Builderbuilder()Creates a builder forSMFAttribute.intcomponentCount()intcomponentSizeBits()intcomponentSizeOctets()SMFComponentTypecomponentType()static SMFAttributecopyOf(SMFAttributeType instance)Creates an immutable copy of aSMFAttributeTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofSMFAttributethat have equal attribute values.inthashCode()Computes a hash code from attributes:name,componentType,componentCount,componentSizeBits,componentSizeOctets,sizeOctets.SMFAttributeNamename()static SMFAttributeof(SMFAttributeName name, SMFComponentType componentType, int componentCount, int componentSizeBits)Construct a new immutableSMFAttributeinstance.intsizeOctets()java.lang.StringtoString()Prints the immutable valueSMFAttributewith attribute values.SMFAttributewithComponentCount(int value)Copy the current immutable object by setting a value for thecomponentCountattribute.SMFAttributewithComponentSizeBits(int value)Copy the current immutable object by setting a value for thecomponentSizeBitsattribute.SMFAttributewithComponentType(SMFComponentType value)Copy the current immutable object by setting a value for thecomponentTypeattribute.SMFAttributewithName(SMFAttributeName value)Copy the current immutable object by setting a value for thenameattribute.-
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:
namein interfaceSMFAttributeType- Returns:
- The name of the attribute
-
componentType
public SMFComponentType componentType()
- Specified by:
componentTypein interfaceSMFAttributeType- Returns:
- The kind of components that make up the attribute
-
componentCount
public int componentCount()
- Specified by:
componentCountin interfaceSMFAttributeType- Returns:
- The number of components in the attribute
-
componentSizeBits
public int componentSizeBits()
- Specified by:
componentSizeBitsin interfaceSMFAttributeType- Returns:
- The size of a single component in bits
-
componentSizeOctets
public int componentSizeOctets()
- Specified by:
componentSizeOctetsin interfaceSMFAttributeType- Returns:
- The size of a single component in octets
-
sizeOctets
public int sizeOctets()
- Specified by:
sizeOctetsin 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 thenameattribute. 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
thisobject
-
withComponentType
public final SMFAttribute withComponentType(SMFComponentType value)
Copy the current immutable object by setting a value for thecomponentTypeattribute. 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
thisobject
-
withComponentCount
public final SMFAttribute withComponentCount(int value)
Copy the current immutable object by setting a value for thecomponentCountattribute. 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
thisobject
-
withComponentSizeBits
public final SMFAttribute withComponentSizeBits(int value)
Copy the current immutable object by setting a value for thecomponentSizeBitsattribute. 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
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFAttributethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:name,componentType,componentCount,componentSizeBits,componentSizeOctets,sizeOctets.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFAttributewith attribute values.- Overrides:
toStringin 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 immutableSMFAttributeinstance.- Parameters:
name- The value for thenameattributecomponentType- The value for thecomponentTypeattributecomponentCount- The value for thecomponentCountattributecomponentSizeBits- The value for thecomponentSizeBitsattribute- Returns:
- An immutable SMFAttribute instance
-
copyOf
public static SMFAttribute copyOf(SMFAttributeType instance)
Creates an immutable copy of aSMFAttributeTypevalue. 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) // requiredname.setComponentType(com.io7m.smfj.core.SMFComponentType) // requiredcomponentType.setComponentCount(int) // requiredcomponentCount.setComponentSizeBits(int) // requiredcomponentSizeBits.build();- Returns:
- A new SMFAttribute builder
-
-