Class SMFB2Section
- java.lang.Object
-
- com.io7m.smfj.format.binary2.internal.SMFB2Section
-
- All Implemented Interfaces:
SMFB2SectionType
public final class SMFB2Section extends java.lang.Object implements SMFB2SectionType
A parsed section.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMFB2Section.Builder
Builds instances of typeSMFB2Section
.
-
Field Summary
-
Fields inherited from interface com.io7m.smfj.format.binary2.internal.SMFB2SectionType
SECTION_ALIGNMENT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SMFB2Section.Builder
builder()
Creates a builder forSMFB2Section
.static SMFB2Section
copyOf(SMFB2SectionType instance)
Creates an immutable copy of aSMFB2SectionType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofSMFB2Section
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:id
,sizeOfData
,offset
,sizeTotal
.long
id()
static SMFB2Section
of(long id, long sizeOfData, long offset)
Construct a new immutableSMFB2Section
instance.long
offset()
long
sizeOfData()
The size of the section data, not including the magic number or this size value.long
sizeTotal()
java.lang.String
toString()
Prints the immutable valueSMFB2Section
with attribute values.SMFB2Section
withId(long value)
Copy the current immutable object by setting a value for theid
attribute.SMFB2Section
withOffset(long value)
Copy the current immutable object by setting a value for theoffset
attribute.SMFB2Section
withSizeOfData(long value)
Copy the current immutable object by setting a value for thesizeOfData
attribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.smfj.format.binary2.internal.SMFB2SectionType
checkPreconditions
-
-
-
-
Method Detail
-
id
public long id()
- Specified by:
id
in interfaceSMFB2SectionType
- Returns:
- The identifier of this section
-
sizeOfData
public long sizeOfData()
The size of the section data, not including the magic number or this size value.
sizeOfData() + 8 + 8
must be a multiple ofSMFB2SectionType.SECTION_ALIGNMENT
- Specified by:
sizeOfData
in interfaceSMFB2SectionType
- Returns:
- The size of this section
-
offset
public long offset()
- Specified by:
offset
in interfaceSMFB2SectionType
- Returns:
- The absolute offset of the start of the section
-
sizeTotal
public long sizeTotal()
- Specified by:
sizeTotal
in interfaceSMFB2SectionType
- Returns:
- The total size of the section: The size of the data plus the header
-
withId
public final SMFB2Section withId(long value)
Copy the current immutable object by setting a value for theid
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for id- Returns:
- A modified copy of the
this
object
-
withSizeOfData
public final SMFB2Section withSizeOfData(long value)
Copy the current immutable object by setting a value for thesizeOfData
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for sizeOfData- Returns:
- A modified copy of the
this
object
-
withOffset
public final SMFB2Section withOffset(long value)
Copy the current immutable object by setting a value for theoffset
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for offset- Returns:
- A modified copy of the
this
object
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFB2Section
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:id
,sizeOfData
,offset
,sizeTotal
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFB2Section
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
of
public static SMFB2Section of(long id, long sizeOfData, long offset)
Construct a new immutableSMFB2Section
instance.- Parameters:
id
- The value for theid
attributesizeOfData
- The value for thesizeOfData
attributeoffset
- The value for theoffset
attribute- Returns:
- An immutable SMFB2Section instance
-
copyOf
public static SMFB2Section copyOf(SMFB2SectionType instance)
Creates an immutable copy of aSMFB2SectionType
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 SMFB2Section instance
-
builder
public static SMFB2Section.Builder builder()
Creates a builder forSMFB2Section
.SMFB2Section.builder() .setId(long) // required
id
.setSizeOfData(long) // requiredsizeOfData
.setOffset(long) // requiredoffset
.build();- Returns:
- A new SMFB2Section builder
-
-