Package com.io7m.waxmill.parser.api
Class WXMParseError
java.lang.Object
com.io7m.waxmill.parser.api.WXMParseError
- All Implemented Interfaces:
com.io7m.jlexing.core.LexicalType<java.net.URI>,WXMParseErrorType
public final class WXMParseError extends java.lang.Object implements WXMParseErrorType
The type of parse errors.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWXMParseError.BuilderBuilds instances of typeWXMParseError.Nested classes/interfaces inherited from interface com.io7m.waxmill.parser.api.WXMParseErrorType
WXMParseErrorType.Severity -
Method Summary
Modifier and Type Method Description static WXMParseError.Builderbuilder()Creates a builder forWXMParseError.static WXMParseErrorcopyOf(WXMParseErrorType instance)Creates an immutable copy of aWXMParseErrorTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofWXMParseErrorthat have equal attribute values.java.util.Optional<java.lang.Exception>exception()inthashCode()Computes a hash code from attributes:lexical,severity,message,exception.com.io7m.jlexing.core.LexicalPosition<java.net.URI>lexical()java.lang.Stringmessage()WXMParseErrorType.Severityseverity()java.lang.StringtoString()Prints the immutable valueWXMParseErrorwith attribute values.WXMParseErrorwithException(java.lang.Exception value)Copy the current immutable object by setting a present value for the optionalexceptionattribute.WXMParseErrorwithException(java.util.Optional<? extends java.lang.Exception> optional)Copy the current immutable object by setting an optional value for theexceptionattribute.WXMParseErrorwithLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI> value)Copy the current immutable object by setting a value for thelexicalattribute.WXMParseErrorwithMessage(java.lang.String value)Copy the current immutable object by setting a value for themessageattribute.WXMParseErrorwithSeverity(WXMParseErrorType.Severity value)Copy the current immutable object by setting a value for theseverityattribute.
-
Method Details
-
lexical
public com.io7m.jlexing.core.LexicalPosition<java.net.URI> lexical()- Specified by:
lexicalin interfacecom.io7m.jlexing.core.LexicalType<java.net.URI>- Specified by:
lexicalin interfaceWXMParseErrorType- Returns:
- The value of the
lexicalattribute
-
severity
- Specified by:
severityin interfaceWXMParseErrorType- Returns:
- The severity of the error
-
message
public java.lang.String message()- Specified by:
messagein interfaceWXMParseErrorType- Returns:
- The parse error message
-
exception
public java.util.Optional<java.lang.Exception> exception()- Specified by:
exceptionin interfaceWXMParseErrorType- Returns:
- The exception raised, if any
-
withLexical
Copy the current immutable object by setting a value for thelexicalattribute. 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
thisobject
-
withSeverity
Copy the current immutable object by setting a value for theseverityattribute. 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
thisobject
-
withMessage
Copy the current immutable object by setting a value for themessageattribute. 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
thisobject
-
withException
Copy the current immutable object by setting a present value for the optionalexceptionattribute.- Parameters:
value- The value for exception- Returns:
- A modified copy of
thisobject
-
withException
public final WXMParseError withException(java.util.Optional<? extends java.lang.Exception> optional)Copy the current immutable object by setting an optional value for theexceptionattribute. 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
thisobject
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofWXMParseErrorthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()Computes a hash code from attributes:lexical,severity,message,exception.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueWXMParseErrorwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aWXMParseErrorTypevalue. 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 WXMParseError instance
-
builder
Creates a builder forWXMParseError.WXMParseError.builder() .setLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI>) // requiredlexical.setSeverity(com.io7m.waxmill.parser.api.WXMParseErrorType.Severity) // requiredseverity.setMessage(String) // requiredmessage.setException(Exception) // optionalexception.build();- Returns:
- A new WXMParseError builder
-