- java.lang.Object
-
- com.io7m.jspiel.api.RiffSize
-
- All Implemented Interfaces:
RiffSizeType
public final class RiffSize extends java.lang.Object implements RiffSizeType
A (possibly padded) size value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRiffSize.BuilderBuilds instances of typeRiffSize.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RiffSize.Builderbuilder()Creates a builder forRiffSize.static RiffSizecopyOf(RiffSizeType instance)Creates an immutable copy of aRiffSizeTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofRiffSizethat have equal attribute values.inthashCode()Computes a hash code from attributes:size,padded.booleanisPadded()static RiffSizeof(long size, boolean padded)Construct a new immutableRiffSizeinstance.longsize()java.lang.StringtoString()Prints the immutable valueRiffSizewith attribute values.RiffSizewithPadded(boolean value)Copy the current immutable object by setting a value for thepaddedattribute.RiffSizewithSize(long value)Copy the current immutable object by setting a value for thesizeattribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.jspiel.api.RiffSizeType
checkPreconditions, sizeUnpadded
-
-
-
-
Method Detail
-
size
public long size()
- Specified by:
sizein interfaceRiffSizeType- Returns:
- The raw size value
-
isPadded
public boolean isPadded()
- Specified by:
isPaddedin interfaceRiffSizeType- Returns:
trueif the size value has an extra padding byte
-
withSize
public final RiffSize withSize(long value)
Copy the current immutable object by setting a value for thesizeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for size- Returns:
- A modified copy of the
thisobject
-
withPadded
public final RiffSize withPadded(boolean value)
Copy the current immutable object by setting a value for thepaddedattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for padded- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofRiffSizethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:size,padded.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueRiffSizewith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static RiffSize of(long size, boolean padded)
Construct a new immutableRiffSizeinstance.- Parameters:
size- The value for thesizeattributepadded- The value for thepaddedattribute- Returns:
- An immutable RiffSize instance
-
copyOf
public static RiffSize copyOf(RiffSizeType instance)
Creates an immutable copy of aRiffSizeTypevalue. 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 RiffSize instance
-
builder
public static RiffSize.Builder builder()
Creates a builder forRiffSize.RiffSize.builder() .setSize(long) // requiredsize.setPadded(boolean) // requiredpadded.build();- Returns:
- A new RiffSize builder
-
-