Package com.io7m.jlexing.core
Class LexicalPositionMutable<F>
java.lang.Object
com.io7m.jlexing.core.LexicalPositionMutable<F>
- Type Parameters:
F- generic parameter F
- All Implemented Interfaces:
LexicalPositionType<F>
A modifiable implementation of the
LexicalPositionType type.
Use the create() static factory methods to create new instances.
Use the toImmutable() method to convert to canonical immutable instances.
LexicalPositionMutable is not thread-safe
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionclear()Clears the object by setting all attributes to their initial values.final intcolumn()final booleanReturnstrueif the required attributecolumnis set.static <F> LexicalPositionMutable<F>create()Construct a modifiable instance ofLexicalPositionType.static <F> LexicalPositionMutable<F>Construct a modifiable instance ofLexicalPositionType.booleanThis instance is equal to all instances ofLexicalPositionMutablethat have equal attribute values.file()from(LexicalPositionType<F> instance) Fill this modifiable instance with attribute values from the providedLexicalPositionTypeinstance.inthashCode()Computes a hash code from attributes:line,column,file.final booleanReturnstrueif all required attributes are set, indicating that the object is initialized.final intline()final booleanReturnstrueif the required attributelineis set.setColumn(int column) Assigns a value to thecolumnattribute.Assigns a present value for the optionalfileattribute.Assigns an optional value forfile.setLine(int line) Assigns a value to thelineattribute.final LexicalPosition<F>Converts toLexicalPosition.toString()Generates a string representation of thisLexicalPositionType.final LexicalPositionMutable<F>Reset an attribute to its initial value.final LexicalPositionMutable<F>Reset an attribute to its initial value.
-
Method Details
-
create
Construct a modifiable instance ofLexicalPositionType. -
create
Construct a modifiable instance ofLexicalPositionType.- Type Parameters:
F- generic parameter F- Returns:
- A new modifiable instance
-
line
public final int line()- Specified by:
linein interfaceLexicalPositionType<F>- Returns:
- The line number
-
column
public final int column()- Specified by:
columnin interfaceLexicalPositionType<F>- Returns:
- The column number
-
file
- Specified by:
filein interfaceLexicalPositionType<F>- Returns:
- The file, if any
-
clear
Clears the object by setting all attributes to their initial values.- Returns:
thisfor use in a chained invocation
-
from
Fill this modifiable instance with attribute values from the providedLexicalPositionTypeinstance. Regular attribute values will be overridden, i.e. replaced with ones of an instance. Any of the instance's absent optional values will not be copied (will not override current values).- Parameters:
instance- The instance from which to copy values- Returns:
thisfor use in a chained invocation
-
setLine
Assigns a value to thelineattribute.- Parameters:
line- The value for line- Returns:
thisfor use in a chained invocation
-
setColumn
Assigns a value to thecolumnattribute.- Parameters:
column- The value for column- Returns:
thisfor use in a chained invocation
-
setFile
Assigns a present value for the optionalfileattribute.- Parameters:
file- A value for file- Returns:
thisfor use in a chained invocation
-
setFile
Assigns an optional value forfile.- Parameters:
file- A value for file- Returns:
thisfor use in a chained invocation
-
lineIsSet
public final boolean lineIsSet()Returnstrueif the required attributelineis set.- Returns:
trueif set
-
columnIsSet
public final boolean columnIsSet()Returnstrueif the required attributecolumnis set.- Returns:
trueif set
-
unsetLine
Reset an attribute to its initial value.- Returns:
thisfor use in a chained invocation
-
unsetColumn
Reset an attribute to its initial value.- Returns:
thisfor use in a chained invocation
-
isInitialized
public final boolean isInitialized()Returnstrueif all required attributes are set, indicating that the object is initialized.- Returns:
trueif set
-
toImmutable
Converts toLexicalPosition.- Returns:
- An immutable instance of LexicalPosition
-
equals
This instance is equal to all instances ofLexicalPositionMutablethat have equal attribute values. An uninitialized instance is equal only to itself. -
hashCode
public int hashCode()Computes a hash code from attributes:line,column,file. -
toString
Generates a string representation of thisLexicalPositionType. If uninitialized, some attribute values may appear as question marks.
-