Package com.io7m.smfj.validation.api
Class SMFSchemaAttribute
- java.lang.Object
-
- com.io7m.smfj.validation.api.SMFSchemaAttribute
-
- All Implemented Interfaces:
SMFSchemaAttributeType
public final class SMFSchemaAttribute extends java.lang.Object implements SMFSchemaAttributeType
A schema for a specific attribute.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMFSchemaAttribute.Builder
Builds instances of typeSMFSchemaAttribute
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFSchemaAttribute.Builder
builder()
Creates a builder forSMFSchemaAttribute
.static SMFSchemaAttribute
copyOf(SMFSchemaAttributeType instance)
Creates an immutable copy of aSMFSchemaAttributeType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchemaAttribute
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:name
,requiredComponentType
,requiredComponentCount
,requiredComponentSize
.SMFAttributeName
name()
static SMFSchemaAttribute
of(SMFAttributeName name, java.util.Optional<? extends SMFComponentType> requiredComponentType, java.util.OptionalInt requiredComponentCount, java.util.OptionalInt requiredComponentSize)
Construct a new immutableSMFSchemaAttribute
instance.java.util.OptionalInt
requiredComponentCount()
java.util.OptionalInt
requiredComponentSize()
java.util.Optional<SMFComponentType>
requiredComponentType()
java.lang.String
toString()
Prints the immutable valueSMFSchemaAttribute
with attribute values.SMFSchemaAttribute
withName(SMFAttributeName value)
Copy the current immutable object by setting a value for thename
attribute.SMFSchemaAttribute
withRequiredComponentCount(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentCount
attribute.SMFSchemaAttribute
withRequiredComponentCount(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentCount
attribute.SMFSchemaAttribute
withRequiredComponentSize(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentSize
attribute.SMFSchemaAttribute
withRequiredComponentSize(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentSize
attribute.SMFSchemaAttribute
withRequiredComponentType(SMFComponentType value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentType
attribute.SMFSchemaAttribute
withRequiredComponentType(java.util.Optional<? extends SMFComponentType> optional)
Copy the current immutable object by setting an optional value for therequiredComponentType
attribute.
-
-
-
Method Detail
-
name
public SMFAttributeName name()
- Specified by:
name
in interfaceSMFSchemaAttributeType
- Returns:
- The name of the attribute
-
requiredComponentType
public java.util.Optional<SMFComponentType> requiredComponentType()
- Specified by:
requiredComponentType
in interfaceSMFSchemaAttributeType
- Returns:
- The required component type, if any
-
requiredComponentCount
public java.util.OptionalInt requiredComponentCount()
- Specified by:
requiredComponentCount
in interfaceSMFSchemaAttributeType
- Returns:
- The required component count, if any
-
requiredComponentSize
public java.util.OptionalInt requiredComponentSize()
- Specified by:
requiredComponentSize
in interfaceSMFSchemaAttributeType
- Returns:
- The required component size in bits, if any
-
withName
public final SMFSchemaAttribute 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
-
withRequiredComponentType
public final SMFSchemaAttribute withRequiredComponentType(SMFComponentType value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentType
attribute.- Parameters:
value
- The value for requiredComponentType- Returns:
- A modified copy of
this
object
-
withRequiredComponentType
public final SMFSchemaAttribute withRequiredComponentType(java.util.Optional<? extends SMFComponentType> optional)
Copy the current immutable object by setting an optional value for therequiredComponentType
attribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for requiredComponentType- Returns:
- A modified copy of
this
object
-
withRequiredComponentCount
public final SMFSchemaAttribute withRequiredComponentCount(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentCount
attribute.- Parameters:
value
- The value for requiredComponentCount- Returns:
- A modified copy of
this
object
-
withRequiredComponentCount
public final SMFSchemaAttribute withRequiredComponentCount(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentCount
attribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for requiredComponentCount- Returns:
- A modified copy of
this
object
-
withRequiredComponentSize
public final SMFSchemaAttribute withRequiredComponentSize(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentSize
attribute.- Parameters:
value
- The value for requiredComponentSize- Returns:
- A modified copy of
this
object
-
withRequiredComponentSize
public final SMFSchemaAttribute withRequiredComponentSize(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentSize
attribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for requiredComponentSize- Returns:
- A modified copy of
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchemaAttribute
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
,requiredComponentType
,requiredComponentCount
,requiredComponentSize
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFSchemaAttribute
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFSchemaAttribute of(SMFAttributeName name, java.util.Optional<? extends SMFComponentType> requiredComponentType, java.util.OptionalInt requiredComponentCount, java.util.OptionalInt requiredComponentSize)
Construct a new immutableSMFSchemaAttribute
instance.- Parameters:
name
- The value for thename
attributerequiredComponentType
- The value for therequiredComponentType
attributerequiredComponentCount
- The value for therequiredComponentCount
attributerequiredComponentSize
- The value for therequiredComponentSize
attribute- Returns:
- An immutable SMFSchemaAttribute instance
-
copyOf
public static SMFSchemaAttribute copyOf(SMFSchemaAttributeType instance)
Creates an immutable copy of aSMFSchemaAttributeType
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 SMFSchemaAttribute instance
-
builder
public static SMFSchemaAttribute.Builder builder()
Creates a builder forSMFSchemaAttribute
.SMFSchemaAttribute.builder() .setName(com.io7m.smfj.core.SMFAttributeName) // required
name
.setRequiredComponentType(com.io7m.smfj.core.SMFComponentType) // optionalrequiredComponentType
.setRequiredComponentCount(int) // optionalrequiredComponentCount
.setRequiredComponentSize(int) // optionalrequiredComponentSize
.build();- Returns:
- A new SMFSchemaAttribute builder
-
-