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 classSMFSchemaAttribute.BuilderBuilds instances of typeSMFSchemaAttribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFSchemaAttribute.Builderbuilder()Creates a builder forSMFSchemaAttribute.static SMFSchemaAttributecopyOf(SMFSchemaAttributeType instance)Creates an immutable copy of aSMFSchemaAttributeTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofSMFSchemaAttributethat have equal attribute values.inthashCode()Computes a hash code from attributes:name,requiredComponentType,requiredComponentCount,requiredComponentSize.SMFAttributeNamename()static SMFSchemaAttributeof(SMFAttributeName name, java.util.Optional<? extends SMFComponentType> requiredComponentType, java.util.OptionalInt requiredComponentCount, java.util.OptionalInt requiredComponentSize)Construct a new immutableSMFSchemaAttributeinstance.java.util.OptionalIntrequiredComponentCount()java.util.OptionalIntrequiredComponentSize()java.util.Optional<SMFComponentType>requiredComponentType()java.lang.StringtoString()Prints the immutable valueSMFSchemaAttributewith attribute values.SMFSchemaAttributewithName(SMFAttributeName value)Copy the current immutable object by setting a value for thenameattribute.SMFSchemaAttributewithRequiredComponentCount(int value)Copy the current immutable object by setting a present value for the optionalrequiredComponentCountattribute.SMFSchemaAttributewithRequiredComponentCount(java.util.OptionalInt optional)Copy the current immutable object by setting an optional value for therequiredComponentCountattribute.SMFSchemaAttributewithRequiredComponentSize(int value)Copy the current immutable object by setting a present value for the optionalrequiredComponentSizeattribute.SMFSchemaAttributewithRequiredComponentSize(java.util.OptionalInt optional)Copy the current immutable object by setting an optional value for therequiredComponentSizeattribute.SMFSchemaAttributewithRequiredComponentType(SMFComponentType value)Copy the current immutable object by setting a present value for the optionalrequiredComponentTypeattribute.SMFSchemaAttributewithRequiredComponentType(java.util.Optional<? extends SMFComponentType> optional)Copy the current immutable object by setting an optional value for therequiredComponentTypeattribute.
-
-
-
Method Detail
-
name
public SMFAttributeName name()
- Specified by:
namein interfaceSMFSchemaAttributeType- Returns:
- The name of the attribute
-
requiredComponentType
public java.util.Optional<SMFComponentType> requiredComponentType()
- Specified by:
requiredComponentTypein interfaceSMFSchemaAttributeType- Returns:
- The required component type, if any
-
requiredComponentCount
public java.util.OptionalInt requiredComponentCount()
- Specified by:
requiredComponentCountin interfaceSMFSchemaAttributeType- Returns:
- The required component count, if any
-
requiredComponentSize
public java.util.OptionalInt requiredComponentSize()
- Specified by:
requiredComponentSizein 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 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
-
withRequiredComponentType
public final SMFSchemaAttribute withRequiredComponentType(SMFComponentType value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentTypeattribute.- Parameters:
value- The value for requiredComponentType- Returns:
- A modified copy of
thisobject
-
withRequiredComponentType
public final SMFSchemaAttribute withRequiredComponentType(java.util.Optional<? extends SMFComponentType> optional)
Copy the current immutable object by setting an optional value for therequiredComponentTypeattribute. 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
thisobject
-
withRequiredComponentCount
public final SMFSchemaAttribute withRequiredComponentCount(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentCountattribute.- Parameters:
value- The value for requiredComponentCount- Returns:
- A modified copy of
thisobject
-
withRequiredComponentCount
public final SMFSchemaAttribute withRequiredComponentCount(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentCountattribute. 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
thisobject
-
withRequiredComponentSize
public final SMFSchemaAttribute withRequiredComponentSize(int value)
Copy the current immutable object by setting a present value for the optionalrequiredComponentSizeattribute.- Parameters:
value- The value for requiredComponentSize- Returns:
- A modified copy of
thisobject
-
withRequiredComponentSize
public final SMFSchemaAttribute withRequiredComponentSize(java.util.OptionalInt optional)
Copy the current immutable object by setting an optional value for therequiredComponentSizeattribute. 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
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchemaAttributethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:name,requiredComponentType,requiredComponentCount,requiredComponentSize.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFSchemaAttributewith attribute values.- Overrides:
toStringin 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 immutableSMFSchemaAttributeinstance.- Parameters:
name- The value for thenameattributerequiredComponentType- The value for therequiredComponentTypeattributerequiredComponentCount- The value for therequiredComponentCountattributerequiredComponentSize- The value for therequiredComponentSizeattribute- Returns:
- An immutable SMFSchemaAttribute instance
-
copyOf
public static SMFSchemaAttribute copyOf(SMFSchemaAttributeType instance)
Creates an immutable copy of aSMFSchemaAttributeTypevalue. 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) // requiredname.setRequiredComponentType(com.io7m.smfj.core.SMFComponentType) // optionalrequiredComponentType.setRequiredComponentCount(int) // optionalrequiredComponentCount.setRequiredComponentSize(int) // optionalrequiredComponentSize.build();- Returns:
- A new SMFSchemaAttribute builder
-
-