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 classSMFSchema.BuilderBuilds instances of typeSMFSchema.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SMFSchemaAllowExtraAttributesallowExtraAttributes()static SMFSchema.Builderbuilder()Creates a builder forSMFSchema.static SMFSchemacopyOf(SMFSchemaType instance)Creates an immutable copy of aSMFSchemaTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofSMFSchemathat have equal attribute values.inthashCode()Computes a hash code from attributes:schemaIdentifier,requiredAttributes,optionalAttributes,requiredCoordinateSystem,allowExtraAttributes,requireTriangles,requireVertices.static SMFSchemaof(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 immutableSMFSchemainstance.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()SMFSchemaRequireTrianglesrequireTriangles()SMFSchemaRequireVerticesrequireVertices()SMFSchemaIdentifierschemaIdentifier()java.lang.StringtoString()Prints the immutable valueSMFSchemawith attribute values.SMFSchemawithAllowExtraAttributes(SMFSchemaAllowExtraAttributes value)Copy the current immutable object by setting a value for theallowExtraAttributesattribute.SMFSchemawithOptionalAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)Copy the current immutable object by replacing theoptionalAttributesmap with the specified map.SMFSchemawithRequiredAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)Copy the current immutable object by replacing therequiredAttributesmap with the specified map.SMFSchemawithRequiredCoordinateSystem(SMFCoordinateSystem value)Copy the current immutable object by setting a present value for the optionalrequiredCoordinateSystemattribute.SMFSchemawithRequiredCoordinateSystem(java.util.Optional<? extends SMFCoordinateSystem> optional)Copy the current immutable object by setting an optional value for therequiredCoordinateSystemattribute.SMFSchemawithRequireTriangles(SMFSchemaRequireTriangles value)Copy the current immutable object by setting a value for therequireTrianglesattribute.SMFSchemawithRequireVertices(SMFSchemaRequireVertices value)Copy the current immutable object by setting a value for therequireVerticesattribute.SMFSchemawithSchemaIdentifier(SMFSchemaIdentifier value)Copy the current immutable object by setting a value for theschemaIdentifierattribute.-
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:
schemaIdentifierin 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:
requiredAttributesin 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:
optionalAttributesin interfaceSMFSchemaType- Returns:
- The optional attributes
-
requiredCoordinateSystem
public java.util.Optional<SMFCoordinateSystem> requiredCoordinateSystem()
- Specified by:
requiredCoordinateSystemin interfaceSMFSchemaType- Returns:
- The required coordinate system, if any
-
allowExtraAttributes
public SMFSchemaAllowExtraAttributes allowExtraAttributes()
- Specified by:
allowExtraAttributesin interfaceSMFSchemaType- Returns:
SMFSchemaAllowExtraAttributes.SMF_EXTRA_ATTRIBUTES_ALLOWEDif the mesh is allowed to contain attributes that are not given inrequiredAttributes()
-
requireTriangles
public SMFSchemaRequireTriangles requireTriangles()
- Specified by:
requireTrianglesin interfaceSMFSchemaType- Returns:
SMFSchemaRequireTriangles.SMF_TRIANGLES_REQUIREDif a non-zero triangle count is required
-
requireVertices
public SMFSchemaRequireVertices requireVertices()
- Specified by:
requireVerticesin interfaceSMFSchemaType- Returns:
SMFSchemaRequireVertices.SMF_VERTICES_REQUIREDif a non-zero vertex count is required
-
withSchemaIdentifier
public final SMFSchema withSchemaIdentifier(SMFSchemaIdentifier value)
Copy the current immutable object by setting a value for theschemaIdentifierattribute. 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
thisobject
-
withRequiredAttributes
public final SMFSchema withRequiredAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing therequiredAttributesmap 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
thisobject
-
withOptionalAttributes
public final SMFSchema withOptionalAttributes(java.util.Map<? extends SMFAttributeName,? extends SMFSchemaAttribute> entries)
Copy the current immutable object by replacing theoptionalAttributesmap 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
thisobject
-
withRequiredCoordinateSystem
public final SMFSchema withRequiredCoordinateSystem(SMFCoordinateSystem value)
Copy the current immutable object by setting a present value for the optionalrequiredCoordinateSystemattribute.- Parameters:
value- The value for requiredCoordinateSystem- Returns:
- A modified copy of
thisobject
-
withRequiredCoordinateSystem
public final SMFSchema withRequiredCoordinateSystem(java.util.Optional<? extends SMFCoordinateSystem> optional)
Copy the current immutable object by setting an optional value for therequiredCoordinateSystemattribute. 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
thisobject
-
withAllowExtraAttributes
public final SMFSchema withAllowExtraAttributes(SMFSchemaAllowExtraAttributes value)
Copy the current immutable object by setting a value for theallowExtraAttributesattribute. 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
thisobject
-
withRequireTriangles
public final SMFSchema withRequireTriangles(SMFSchemaRequireTriangles value)
Copy the current immutable object by setting a value for therequireTrianglesattribute. 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
thisobject
-
withRequireVertices
public final SMFSchema withRequireVertices(SMFSchemaRequireVertices value)
Copy the current immutable object by setting a value for therequireVerticesattribute. 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
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFSchemathat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:schemaIdentifier,requiredAttributes,optionalAttributes,requiredCoordinateSystem,allowExtraAttributes,requireTriangles,requireVertices.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFSchemawith attribute values.- Overrides:
toStringin 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 immutableSMFSchemainstance.- Parameters:
schemaIdentifier- The value for theschemaIdentifierattributerequiredAttributes- The value for therequiredAttributesattributeoptionalAttributes- The value for theoptionalAttributesattributerequiredCoordinateSystem- The value for therequiredCoordinateSystemattributeallowExtraAttributes- The value for theallowExtraAttributesattributerequireTriangles- The value for therequireTrianglesattributerequireVertices- The value for therequireVerticesattribute- Returns:
- An immutable SMFSchema instance
-
copyOf
public static SMFSchema copyOf(SMFSchemaType instance)
Creates an immutable copy of aSMFSchemaTypevalue. 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) // requiredschemaIdentifier.putRequiredAttributes|putAllRequiredAttributes(com.io7m.smfj.core.SMFAttributeName => SMFSchemaAttribute) //requiredAttributesmappings .putOptionalAttributes|putAllOptionalAttributes(com.io7m.smfj.core.SMFAttributeName => SMFSchemaAttribute) //optionalAttributesmappings .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
-
-