Package com.io7m.smfj.core
Class SMFHeader
- java.lang.Object
-
- com.io7m.smfj.core.SMFHeader
-
- All Implemented Interfaces:
SMFHeaderType
public final class SMFHeader extends java.lang.Object implements SMFHeaderType
Information about an SMF file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMFHeader.Builder
Builds instances of typeSMFHeader
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.SortedMap<SMFAttributeName,SMFAttribute>
attributesByName()
java.util.List<SMFAttribute>
attributesInOrder()
static SMFHeader.Builder
builder()
Creates a builder forSMFHeader
.SMFCoordinateSystem
coordinateSystem()
static SMFHeader
copyOf(SMFHeaderType instance)
Creates an immutable copy of aSMFHeaderType
value.java.nio.ByteOrder
dataByteOrder()
boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFHeader
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:triangles
,vertexCount
,schemaIdentifier
,coordinateSystem
,dataByteOrder
,attributesInOrder
,attributesByName
.static SMFHeader
of(SMFTriangles triangles, long vertexCount, java.util.Optional<? extends SMFSchemaIdentifier> schemaIdentifier, SMFCoordinateSystem coordinateSystem, java.nio.ByteOrder dataByteOrder, java.lang.Iterable<? extends SMFAttribute> attributesInOrder)
Construct a new immutableSMFHeader
instance.static SMFHeader
of(SMFTriangles triangles, long vertexCount, java.util.Optional<SMFSchemaIdentifier> schemaIdentifier, SMFCoordinateSystem coordinateSystem, java.nio.ByteOrder dataByteOrder, java.util.List<SMFAttribute> attributesInOrder)
Construct a new immutableSMFHeader
instance.java.util.Optional<SMFSchemaIdentifier>
schemaIdentifier()
java.lang.String
toString()
Prints the immutable valueSMFHeader
with attribute values.SMFTriangles
triangles()
long
vertexCount()
SMFHeader
withAttributesInOrder(SMFAttribute... elements)
Copy the current immutable object with elements that replace the content ofattributesInOrder
.SMFHeader
withAttributesInOrder(java.lang.Iterable<? extends SMFAttribute> elements)
Copy the current immutable object with elements that replace the content ofattributesInOrder
.SMFHeader
withCoordinateSystem(SMFCoordinateSystem value)
Copy the current immutable object by setting a value for thecoordinateSystem
attribute.SMFHeader
withDataByteOrder(java.nio.ByteOrder value)
Copy the current immutable object by setting a value for thedataByteOrder
attribute.SMFHeader
withSchemaIdentifier(SMFSchemaIdentifier value)
Copy the current immutable object by setting a present value for the optionalschemaIdentifier
attribute.SMFHeader
withSchemaIdentifier(java.util.Optional<? extends SMFSchemaIdentifier> optional)
Copy the current immutable object by setting an optional value for theschemaIdentifier
attribute.SMFHeader
withTriangles(SMFTriangles value)
Copy the current immutable object by setting a value for thetriangles
attribute.SMFHeader
withVertexCount(long value)
Copy the current immutable object by setting a value for thevertexCount
attribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.smfj.core.SMFHeaderType
checkPreconditions
-
-
-
-
Method Detail
-
triangles
public SMFTriangles triangles()
- Specified by:
triangles
in interfaceSMFHeaderType
- Returns:
- The triangle information for the file
-
vertexCount
public long vertexCount()
- Specified by:
vertexCount
in interfaceSMFHeaderType
- Returns:
- The number of vertices in the file
-
schemaIdentifier
public java.util.Optional<SMFSchemaIdentifier> schemaIdentifier()
- Specified by:
schemaIdentifier
in interfaceSMFHeaderType
- Returns:
- The schema ID in the file
-
coordinateSystem
public SMFCoordinateSystem coordinateSystem()
- Specified by:
coordinateSystem
in interfaceSMFHeaderType
- Returns:
- The coordinate system of the mesh data
-
dataByteOrder
public java.nio.ByteOrder dataByteOrder()
- Specified by:
dataByteOrder
in interfaceSMFHeaderType
- Returns:
- The endianness of the mesh data
-
attributesInOrder
public java.util.List<SMFAttribute> attributesInOrder()
- Specified by:
attributesInOrder
in interfaceSMFHeaderType
- Returns:
- The attributes in the order that they appeared in the file
-
attributesByName
public java.util.SortedMap<SMFAttributeName,SMFAttribute> attributesByName()
- Specified by:
attributesByName
in interfaceSMFHeaderType
- Returns:
- The attributes by name
-
withTriangles
public final SMFHeader withTriangles(SMFTriangles value)
Copy the current immutable object by setting a value for thetriangles
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for triangles- Returns:
- A modified copy of the
this
object
-
withVertexCount
public final SMFHeader withVertexCount(long value)
Copy the current immutable object by setting a value for thevertexCount
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for vertexCount- Returns:
- A modified copy of the
this
object
-
withSchemaIdentifier
public final SMFHeader withSchemaIdentifier(SMFSchemaIdentifier value)
Copy the current immutable object by setting a present value for the optionalschemaIdentifier
attribute.- Parameters:
value
- The value for schemaIdentifier- Returns:
- A modified copy of
this
object
-
withSchemaIdentifier
public final SMFHeader withSchemaIdentifier(java.util.Optional<? extends SMFSchemaIdentifier> optional)
Copy the current immutable object by setting an optional value for theschemaIdentifier
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 schemaIdentifier- Returns:
- A modified copy of
this
object
-
withCoordinateSystem
public final SMFHeader withCoordinateSystem(SMFCoordinateSystem value)
Copy the current immutable object by setting a value for thecoordinateSystem
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for coordinateSystem- Returns:
- A modified copy of the
this
object
-
withDataByteOrder
public final SMFHeader withDataByteOrder(java.nio.ByteOrder value)
Copy the current immutable object by setting a value for thedataByteOrder
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for dataByteOrder- Returns:
- A modified copy of the
this
object
-
withAttributesInOrder
public final SMFHeader withAttributesInOrder(SMFAttribute... elements)
Copy the current immutable object with elements that replace the content ofattributesInOrder
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withAttributesInOrder
public final SMFHeader withAttributesInOrder(java.lang.Iterable<? extends SMFAttribute> elements)
Copy the current immutable object with elements that replace the content ofattributesInOrder
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of attributesInOrder elements to set- Returns:
- A modified copy of
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFHeader
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:triangles
,vertexCount
,schemaIdentifier
,coordinateSystem
,dataByteOrder
,attributesInOrder
,attributesByName
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFHeader
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFHeader of(SMFTriangles triangles, long vertexCount, java.util.Optional<SMFSchemaIdentifier> schemaIdentifier, SMFCoordinateSystem coordinateSystem, java.nio.ByteOrder dataByteOrder, java.util.List<SMFAttribute> attributesInOrder)
Construct a new immutableSMFHeader
instance.- Parameters:
triangles
- The value for thetriangles
attributevertexCount
- The value for thevertexCount
attributeschemaIdentifier
- The value for theschemaIdentifier
attributecoordinateSystem
- The value for thecoordinateSystem
attributedataByteOrder
- The value for thedataByteOrder
attributeattributesInOrder
- The value for theattributesInOrder
attribute- Returns:
- An immutable SMFHeader instance
-
of
public static SMFHeader of(SMFTriangles triangles, long vertexCount, java.util.Optional<? extends SMFSchemaIdentifier> schemaIdentifier, SMFCoordinateSystem coordinateSystem, java.nio.ByteOrder dataByteOrder, java.lang.Iterable<? extends SMFAttribute> attributesInOrder)
Construct a new immutableSMFHeader
instance.- Parameters:
triangles
- The value for thetriangles
attributevertexCount
- The value for thevertexCount
attributeschemaIdentifier
- The value for theschemaIdentifier
attributecoordinateSystem
- The value for thecoordinateSystem
attributedataByteOrder
- The value for thedataByteOrder
attributeattributesInOrder
- The value for theattributesInOrder
attribute- Returns:
- An immutable SMFHeader instance
-
copyOf
public static SMFHeader copyOf(SMFHeaderType instance)
Creates an immutable copy of aSMFHeaderType
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 SMFHeader instance
-
builder
public static SMFHeader.Builder builder()
Creates a builder forSMFHeader
.SMFHeader.builder() .setTriangles(com.io7m.smfj.core.SMFTriangles) // optional
triangles
.setVertexCount(long) // optionalvertexCount
.setSchemaIdentifier(SMFSchemaIdentifier) // optionalschemaIdentifier
.setCoordinateSystem(com.io7m.smfj.core.SMFCoordinateSystem) // optionalcoordinateSystem
.setDataByteOrder(java.nio.ByteOrder) // optionaldataByteOrder
.addAttributesInOrder|addAllAttributesInOrder(SMFAttribute) //attributesInOrder
elements .build();- Returns:
- A new SMFHeader builder
-
-