Package com.io7m.smfj.validation.api
Class SMFSchema
- java.lang.Object
-
- com.io7m.smfj.validation.api.SMFSchema
-
- All Implemented Interfaces:
SMFSchemaType
public final class SMFSchema extends java.lang.Object implements SMFSchemaType
The type of schemas.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMFSchema.Builder
Builds instances of typeSMFSchema
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SMFSchemaAllowExtraAttributes
allowExtraAttributes()
static SMFSchema.Builder
builder()
Creates a builder forSMFSchema
.static SMFSchema
copyOf(SMFSchemaType instance)
Creates an immutable copy of aSMFSchemaType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchema
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:schemaIdentifier
,requiredAttributes
,optionalAttributes
,requiredCoordinateSystem
,allowExtraAttributes
,requireTriangles
,requireVertices
.static SMFSchema
of(SMFSchemaIdentifier schemaIdentifier, java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> requiredAttributes, java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> optionalAttributes, java.util.Optional<? extends SMFCoordinateSystem> requiredCoordinateSystem, SMFSchemaAllowExtraAttributes allowExtraAttributes, SMFSchemaRequireTriangles requireTriangles, SMFSchemaRequireVertices requireVertices)
Construct a new immutableSMFSchema
instance.java.util.Map<SMFAttributeName,SMFSchemaAttribute>
optionalAttributes()
A schema may define optional attributes.java.util.Map<SMFAttributeName,SMFSchemaAttribute>
requiredAttributes()
A schema may define required attributes.java.util.Optional<SMFCoordinateSystem>
requiredCoordinateSystem()
SMFSchemaRequireTriangles
requireTriangles()
SMFSchemaRequireVertices
requireVertices()
SMFSchemaIdentifier
schemaIdentifier()
java.lang.String
toString()
Prints the immutable valueSMFSchema
with attribute values.SMFSchema
withAllowExtraAttributes(SMFSchemaAllowExtraAttributes value)
Copy the current immutable object by setting a value for theallowExtraAttributes
attribute.SMFSchema
withOptionalAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing theoptionalAttributes
map with the specified map.SMFSchema
withRequiredAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing therequiredAttributes
map with the specified map.SMFSchema
withRequiredCoordinateSystem(SMFCoordinateSystem value)
Copy the current immutable object by setting a present value for the optionalrequiredCoordinateSystem
attribute.SMFSchema
withRequiredCoordinateSystem(java.util.Optional<? extends SMFCoordinateSystem> optional)
Copy the current immutable object by setting an optional value for therequiredCoordinateSystem
attribute.SMFSchema
withRequireTriangles(SMFSchemaRequireTriangles value)
Copy the current immutable object by setting a value for therequireTriangles
attribute.SMFSchema
withRequireVertices(SMFSchemaRequireVertices value)
Copy the current immutable object by setting a value for therequireVertices
attribute.SMFSchema
withSchemaIdentifier(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaIdentifier
attribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.smfj.validation.api.SMFSchemaType
checkPreconditions
-
-
-
-
Method Detail
-
schemaIdentifier
public SMFSchemaIdentifier schemaIdentifier()
- Specified by:
schemaIdentifier
in interfaceSMFSchemaType
- Returns:
- The unique schema identifier
-
requiredAttributes
public java.util.Map<SMFAttributeName,SMFSchemaAttribute> requiredAttributes()
A schema may define required attributes. An attribute is not allowed to be both required and optional at the same time.- Specified by:
requiredAttributes
in interfaceSMFSchemaType
- Returns:
- The required attributes
-
optionalAttributes
public java.util.Map<SMFAttributeName,SMFSchemaAttribute> optionalAttributes()
A schema may define optional attributes. An attribute is not allowed to be both required and optional at the same time.- Specified by:
optionalAttributes
in interfaceSMFSchemaType
- Returns:
- The optional attributes
-
requiredCoordinateSystem
public java.util.Optional<SMFCoordinateSystem> requiredCoordinateSystem()
- Specified by:
requiredCoordinateSystem
in interfaceSMFSchemaType
- Returns:
- The required coordinate system, if any
-
allowExtraAttributes
public SMFSchemaAllowExtraAttributes allowExtraAttributes()
- Specified by:
allowExtraAttributes
in interfaceSMFSchemaType
- Returns:
SMFSchemaAllowExtraAttributes.SMF_EXTRA_ATTRIBUTES_ALLOWED
if the mesh is allowed to contain attributes that are not given inrequiredAttributes()
-
requireTriangles
public SMFSchemaRequireTriangles requireTriangles()
- Specified by:
requireTriangles
in interfaceSMFSchemaType
- Returns:
SMFSchemaRequireTriangles.SMF_TRIANGLES_REQUIRED
if a non-zero triangle count is required
-
requireVertices
public SMFSchemaRequireVertices requireVertices()
- Specified by:
requireVertices
in interfaceSMFSchemaType
- Returns:
SMFSchemaRequireVertices.SMF_VERTICES_REQUIRED
if a non-zero vertex count is required
-
withSchemaIdentifier
public final SMFSchema withSchemaIdentifier(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaIdentifier
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for schemaIdentifier- Returns:
- A modified copy of the
this
object
-
withRequiredAttributes
public final SMFSchema withRequiredAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing therequiredAttributes
map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
entries
- The entries to be added to the requiredAttributes map- Returns:
- A modified copy of
this
object
-
withOptionalAttributes
public final SMFSchema withOptionalAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing theoptionalAttributes
map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
entries
- The entries to be added to the optionalAttributes map- Returns:
- A modified copy of
this
object
-
withRequiredCoordinateSystem
public final SMFSchema withRequiredCoordinateSystem(SMFCoordinateSystem value)
Copy the current immutable object by setting a present value for the optionalrequiredCoordinateSystem
attribute.- Parameters:
value
- The value for requiredCoordinateSystem- Returns:
- A modified copy of
this
object
-
withRequiredCoordinateSystem
public final SMFSchema withRequiredCoordinateSystem(java.util.Optional<? extends SMFCoordinateSystem> optional)
Copy the current immutable object by setting an optional value for therequiredCoordinateSystem
attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for requiredCoordinateSystem- Returns:
- A modified copy of
this
object
-
withAllowExtraAttributes
public final SMFSchema withAllowExtraAttributes(SMFSchemaAllowExtraAttributes value)
Copy the current immutable object by setting a value for theallowExtraAttributes
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for allowExtraAttributes- Returns:
- A modified copy of the
this
object
-
withRequireTriangles
public final SMFSchema withRequireTriangles(SMFSchemaRequireTriangles value)
Copy the current immutable object by setting a value for therequireTriangles
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for requireTriangles- Returns:
- A modified copy of the
this
object
-
withRequireVertices
public final SMFSchema withRequireVertices(SMFSchemaRequireVertices value)
Copy the current immutable object by setting a value for therequireVertices
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for requireVertices- Returns:
- A modified copy of the
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchema
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:schemaIdentifier
,requiredAttributes
,optionalAttributes
,requiredCoordinateSystem
,allowExtraAttributes
,requireTriangles
,requireVertices
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFSchema
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFSchema of(SMFSchemaIdentifier schemaIdentifier, java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> requiredAttributes, java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> optionalAttributes, java.util.Optional<? extends SMFCoordinateSystem> requiredCoordinateSystem, SMFSchemaAllowExtraAttributes allowExtraAttributes, SMFSchemaRequireTriangles requireTriangles, SMFSchemaRequireVertices requireVertices)
Construct a new immutableSMFSchema
instance.- Parameters:
schemaIdentifier
- The value for theschemaIdentifier
attributerequiredAttributes
- The value for therequiredAttributes
attributeoptionalAttributes
- The value for theoptionalAttributes
attributerequiredCoordinateSystem
- The value for therequiredCoordinateSystem
attributeallowExtraAttributes
- The value for theallowExtraAttributes
attributerequireTriangles
- The value for therequireTriangles
attributerequireVertices
- The value for therequireVertices
attribute- Returns:
- An immutable SMFSchema instance
-
copyOf
public static SMFSchema copyOf(SMFSchemaType instance)
Creates an immutable copy of aSMFSchemaType
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 SMFSchema instance
-
builder
public static SMFSchema.Builder builder()
Creates a builder forSMFSchema
.SMFSchema.builder() .setSchemaIdentifier(com.io7m.smfj.core.SMFSchemaIdentifier) // required
schemaIdentifier
.putRequiredAttributes|putAllRequiredAttributes(com.io7m.smfj.core.SMFAttributeName => SMFSchemaAttribute) //requiredAttributes
mappings .putOptionalAttributes|putAllOptionalAttributes(com.io7m.smfj.core.SMFAttributeName => SMFSchemaAttribute) //optionalAttributes
mappings .setRequiredCoordinateSystem(com.io7m.smfj.core.SMFCoordinateSystem) // optionalrequiredCoordinateSystem
.setAllowExtraAttributes(com.io7m.smfj.validation.api.SMFSchemaAllowExtraAttributes) // optionalallowExtraAttributes
.setRequireTriangles(com.io7m.smfj.validation.api.SMFSchemaRequireTriangles) // optionalrequireTriangles
.setRequireVertices(com.io7m.smfj.validation.api.SMFSchemaRequireVertices) // optionalrequireVertices
.build();- Returns:
- A new SMFSchema builder
-
-