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 classSMFB2Section.BuilderBuilds 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.Builderbuilder()Creates a builder forSMFB2Section.static SMFB2SectioncopyOf(SMFB2SectionType instance)Creates an immutable copy of aSMFB2SectionTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofSMFB2Sectionthat have equal attribute values.inthashCode()Computes a hash code from attributes:id,sizeOfData,offset,sizeTotal.longid()static SMFB2Sectionof(long id, long sizeOfData, long offset)Construct a new immutableSMFB2Sectioninstance.longoffset()longsizeOfData()The size of the section data, not including the magic number or this size value.longsizeTotal()java.lang.StringtoString()Prints the immutable valueSMFB2Sectionwith attribute values.SMFB2SectionwithId(long value)Copy the current immutable object by setting a value for theidattribute.SMFB2SectionwithOffset(long value)Copy the current immutable object by setting a value for theoffsetattribute.SMFB2SectionwithSizeOfData(long value)Copy the current immutable object by setting a value for thesizeOfDataattribute.-
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:
idin 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 + 8must be a multiple ofSMFB2SectionType.SECTION_ALIGNMENT- Specified by:
sizeOfDatain interfaceSMFB2SectionType- Returns:
- The size of this section
-
offset
public long offset()
- Specified by:
offsetin interfaceSMFB2SectionType- Returns:
- The absolute offset of the start of the section
-
sizeTotal
public long sizeTotal()
- Specified by:
sizeTotalin 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 theidattribute. 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
thisobject
-
withSizeOfData
public final SMFB2Section withSizeOfData(long value)
Copy the current immutable object by setting a value for thesizeOfDataattribute. 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
thisobject
-
withOffset
public final SMFB2Section withOffset(long value)
Copy the current immutable object by setting a value for theoffsetattribute. 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
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofSMFB2Sectionthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:id,sizeOfData,offset,sizeTotal.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueSMFB2Sectionwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static SMFB2Section of(long id, long sizeOfData, long offset)
Construct a new immutableSMFB2Sectioninstance.- Parameters:
id- The value for theidattributesizeOfData- The value for thesizeOfDataattributeoffset- The value for theoffsetattribute- Returns:
- An immutable SMFB2Section instance
-
copyOf
public static SMFB2Section copyOf(SMFB2SectionType instance)
Creates an immutable copy of aSMFB2SectionTypevalue. 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) // requiredid.setSizeOfData(long) // requiredsizeOfData.setOffset(long) // requiredoffset.build();- Returns:
- A new SMFB2Section builder
-
-