Package com.io7m.jnoisetype.api
Class NTSource
- java.lang.Object
-
- com.io7m.jnoisetype.api.NTSource
-
- All Implemented Interfaces:
NTSourceType
public final class NTSource extends java.lang.Object implements NTSourceType
A location in a binary file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNTSource.BuilderBuilds instances of typeNTSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NTSource.Builderbuilder()Creates a builder forNTSource.static NTSourcecopyOf(NTSourceType instance)Creates an immutable copy of aNTSourceTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofNTSourcethat have equal attribute values.inthashCode()Computes a hash code from attributes:source,offset.static NTSourceof(java.net.URI source, long offset)Construct a new immutableNTSourceinstance.longoffset()java.net.URIsource()java.lang.StringtoString()Prints the immutable valueNTSourcewith attribute values.NTSourcewithOffset(long value)Copy the current immutable object by setting a value for theoffsetattribute.NTSourcewithSource(java.net.URI value)Copy the current immutable object by setting a value for thesourceattribute.
-
-
-
Method Detail
-
source
public java.net.URI source()
- Specified by:
sourcein interfaceNTSourceType- Returns:
- The source URI
-
offset
public long offset()
- Specified by:
offsetin interfaceNTSourceType- Returns:
- The source offset in octets
-
withSource
public final NTSource withSource(java.net.URI value)
Copy the current immutable object by setting a value for thesourceattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for source- Returns:
- A modified copy of the
thisobject
-
withOffset
public final NTSource 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 ofNTSourcethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:source,offset.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueNTSourcewith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static NTSource of(java.net.URI source, long offset)
Construct a new immutableNTSourceinstance.- Parameters:
source- The value for thesourceattributeoffset- The value for theoffsetattribute- Returns:
- An immutable NTSource instance
-
copyOf
public static NTSource copyOf(NTSourceType instance)
Creates an immutable copy of aNTSourceTypevalue. 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 NTSource instance
-
builder
public static NTSource.Builder builder()
Creates a builder forNTSource.NTSource.builder() .setSource(java.net.URI) // requiredsource.setOffset(long) // requiredoffset.build();- Returns:
- A new NTSource builder
-
-