Package com.io7m.changelog.parser.api
Class CParseError
java.lang.Object
com.io7m.changelog.parser.api.CParseError
- All Implemented Interfaces:
CParseErrorType
public final class CParseError extends java.lang.Object implements CParseErrorType
The type of parse errors.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCParseError.BuilderBuilds instances of typeCParseError.Nested classes/interfaces inherited from interface com.io7m.changelog.parser.api.CParseErrorType
CParseErrorType.Severity -
Method Summary
Modifier and Type Method Description static CParseError.Builderbuilder()Creates a builder forCParseError.static CParseErrorcopyOf(CParseErrorType instance)Creates an immutable copy of aCParseErrorTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofCParseErrorthat 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()static CParseErrorof(com.io7m.jlexing.core.LexicalPosition<java.net.URI> lexical, CParseErrorType.Severity severity, java.lang.String message, java.util.Optional<? extends java.lang.Exception> exception)Construct a new immutableCParseErrorinstance.CParseErrorType.Severityseverity()java.lang.StringtoString()Prints the immutable valueCParseErrorwith attribute values.CParseErrorwithException(java.lang.Exception value)Copy the current immutable object by setting a present value for the optionalexceptionattribute.CParseErrorwithException(java.util.Optional<? extends java.lang.Exception> optional)Copy the current immutable object by setting an optional value for theexceptionattribute.CParseErrorwithLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI> value)Copy the current immutable object by setting a value for thelexicalattribute.CParseErrorwithMessage(java.lang.String value)Copy the current immutable object by setting a value for themessageattribute.CParseErrorwithSeverity(CParseErrorType.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 interfaceCParseErrorType- Returns:
- The lexical position of the error
-
severity
- Specified by:
severityin interfaceCParseErrorType- Returns:
- The severity of the error
-
message
public java.lang.String message()- Specified by:
messagein interfaceCParseErrorType- Returns:
- The error message
-
exception
public java.util.Optional<java.lang.Exception> exception()- Specified by:
exceptionin interfaceCParseErrorType- 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
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 ofCParseErrorthat 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 valueCParseErrorwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static CParseError of(com.io7m.jlexing.core.LexicalPosition<java.net.URI> lexical, CParseErrorType.Severity severity, java.lang.String message, java.util.Optional<? extends java.lang.Exception> exception)Construct a new immutableCParseErrorinstance.- Parameters:
lexical- The value for thelexicalattributeseverity- The value for theseverityattributemessage- The value for themessageattributeexception- The value for theexceptionattribute- Returns:
- An immutable CParseError instance
-
copyOf
Creates an immutable copy of aCParseErrorTypevalue. 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 CParseError instance
-
builder
Creates a builder forCParseError.CParseError.builder() .setLexical(com.io7m.jlexing.core.LexicalPosition<java.net.URI>) // requiredlexical.setSeverity(com.io7m.changelog.parser.api.CParseErrorType.Severity) // requiredseverity.setMessage(String) // requiredmessage.setException(Exception) // optionalexception.build();- Returns:
- A new CParseError builder
-