Class ParseError
java.lang.Object
com.io7m.coffeepick.runtime.parser.spi.ParseError
- All Implemented Interfaces:
ParseErrorType
,com.io7m.jlexing.core.LexicalType<java.net.URI>
public final class ParseError extends java.lang.Object implements ParseErrorType
The type of parse errors.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParseError.Builder
Builds instances of typeParseError
.Nested classes/interfaces inherited from interface com.io7m.coffeepick.runtime.parser.spi.ParseErrorType
ParseErrorType.Severity
-
Method Summary
Modifier and Type Method Description static ParseError.Builder
builder()
Creates a builder forParseError
.static ParseError
copyOf(ParseErrorType instance)
Creates an immutable copy of aParseErrorType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofParseError
that have equal attribute values.java.util.Optional<java.lang.Exception>
exception()
int
hashCode()
Computes a hash code from attributes:lexical
,severity
,message
,exception
.com.io7m.jlexing.core.LexicalPosition<java.net.URI>
lexical()
java.lang.String
message()
ParseErrorType.Severity
severity()
java.lang.String
toString()
Prints the immutable valueParseError
with attribute values.ParseError
withException(java.lang.Exception value)
Copy the current immutable object by setting a present value for the optionalexception
attribute.ParseError
withException(java.util.Optional<? extends java.lang.Exception> optional)
Copy the current immutable object by setting an optional value for theexception
attribute.ParseError
withLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI> value)
Copy the current immutable object by setting a value for thelexical
attribute.ParseError
withMessage(java.lang.String value)
Copy the current immutable object by setting a value for themessage
attribute.ParseError
withSeverity(ParseErrorType.Severity value)
Copy the current immutable object by setting a value for theseverity
attribute.
-
Method Details
-
lexical
public com.io7m.jlexing.core.LexicalPosition<java.net.URI> lexical()- Specified by:
lexical
in interfacecom.io7m.jlexing.core.LexicalType<java.net.URI>
- Specified by:
lexical
in interfaceParseErrorType
- Returns:
- The value of the
lexical
attribute
-
severity
- Specified by:
severity
in interfaceParseErrorType
- Returns:
- The error severity
-
message
public java.lang.String message()- Specified by:
message
in interfaceParseErrorType
- Returns:
- The error message
-
exception
public java.util.Optional<java.lang.Exception> exception()- Specified by:
exception
in interfaceParseErrorType
- Returns:
- The exception raised, if any
-
withLexical
Copy the current immutable object by setting a value for thelexical
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for lexical- Returns:
- A modified copy of the
this
object
-
withSeverity
Copy the current immutable object by setting a value for theseverity
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for severity- Returns:
- A modified copy of the
this
object
-
withMessage
Copy the current immutable object by setting a value for themessage
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for message- Returns:
- A modified copy of the
this
object
-
withException
Copy the current immutable object by setting a present value for the optionalexception
attribute.- Parameters:
value
- The value for exception- Returns:
- A modified copy of
this
object
-
withException
Copy the current immutable object by setting an optional value for theexception
attribute. 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 exception- Returns:
- A modified copy of
this
object
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofParseError
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
instance
-
hashCode
public int hashCode()Computes a hash code from attributes:lexical
,severity
,message
,exception
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueParseError
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aParseErrorType
value. 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 ParseError instance
-
builder
Creates a builder forParseError
.ParseError.builder() .setLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI>) // required
lexical
.setSeverity(com.io7m.coffeepick.runtime.parser.spi.ParseErrorType.Severity) // requiredseverity
.setMessage(String) // requiredmessage
.setException(Exception) // optionalexception
.build();- Returns:
- A new ParseError builder
-