Package com.io7m.jlexing.core
Class LexicalPosition<F>
java.lang.Object
com.io7m.jlexing.core.LexicalPosition<F>
- Type Parameters:
F- The type of file information
- All Implemented Interfaces:
LexicalPositionType<F>
The type of lexical positions.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <F> LexicalPosition.Builder<F>builder()Creates a builder forLexicalPosition.intcolumn()static <F> LexicalPosition<F>copyOf(LexicalPositionType<F> instance) Creates an immutable copy of aLexicalPositionTypevalue.booleanThis instance is equal to all instances ofLexicalPositionthat have equal attribute values.file()inthashCode()Computes a hash code from attributes:line,column,file.intline()static <F> LexicalPosition<F>Construct a new immutableLexicalPositioninstance.toString()Prints the immutable valueLexicalPositionwith attribute values.final LexicalPosition<F>withColumn(int value) Copy the current immutable object by setting a value for thecolumnattribute.final LexicalPosition<F>Copy the current immutable object by setting a present value for the optionalfileattribute.final LexicalPosition<F>Copy the current immutable object by setting an optional value for thefileattribute.final LexicalPosition<F>withLine(int value) Copy the current immutable object by setting a value for thelineattribute.
-
Method Details
-
line
public int line()- Specified by:
linein interfaceLexicalPositionType<F>- Returns:
- The line number
-
column
public int column()- Specified by:
columnin interfaceLexicalPositionType<F>- Returns:
- The column number
-
file
- Specified by:
filein interfaceLexicalPositionType<F>- Returns:
- The file, if any
-
withLine
Copy the current immutable object by setting a value for thelineattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for line- Returns:
- A modified copy of the
thisobject
-
withColumn
Copy the current immutable object by setting a value for thecolumnattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for column- Returns:
- A modified copy of the
thisobject
-
withFile
Copy the current immutable object by setting a present value for the optionalfileattribute.- Parameters:
value- The value for file- Returns:
- A modified copy of
thisobject
-
withFile
Copy the current immutable object by setting an optional value for thefileattribute. 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 file- Returns:
- A modified copy of
thisobject
-
equals
This instance is equal to all instances ofLexicalPositionthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:line,column,file. -
toString
Prints the immutable valueLexicalPositionwith attribute values. -
of
Construct a new immutableLexicalPositioninstance.- Parameters:
line- The value for thelineattributecolumn- The value for thecolumnattributefile- The value for thefileattribute- Returns:
- An immutable LexicalPosition instance
-
copyOf
Creates an immutable copy of aLexicalPositionTypevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
F- generic parameter F- Parameters:
instance- The instance to copy- Returns:
- A copied immutable LexicalPosition instance
-
builder
Creates a builder forLexicalPosition.- Type Parameters:
F- generic parameter F- Returns:
- A new LexicalPosition builder
-