Class ParseResult

java.lang.Object
com.attribyte.parser.ParseResult

public class ParseResult extends Object
A parsed resource, on successful parse along with any errors.
Author:
Matt Hamer
  • Field Details

    • resource

      public final Optional<Resource> resource
      The resource, if parse was successful.
    • errors

      public final com.google.common.collect.ImmutableList<ParseError> errors
      An immutable list of errors.
    • parserName

      public final String parserName
      The name of the parser used to create this result.
  • Constructor Details

    • ParseResult

      public ParseResult(String parserName, Resource resource)
      Creates a parse result with a parsed resource and no errors.
      Parameters:
      parserName - The name of the parser that created the result.
      resource - The resource.
    • ParseResult

      public ParseResult(String parserName, ParseError error)
      Creates a parse result with a single error and no parsed resource.
      Parameters:
      parserName - The name of the parser that created the result.
      error - The error.
    • ParseResult

      public ParseResult(String parserName, List<ParseError> errors)
      Creates a parse result with a list of errors and no parsed resource.
      Parameters:
      parserName - The name of the parser that created the result.
      errors - The errors.
    • ParseResult

      public ParseResult(String parserName, Resource resource, List<ParseError> errors)
      Creates a parse result with a parsed resource and a list of (non-fatal) errors.
      Parameters:
      parserName - The name of the parser that created the result.
      resource - The resource.
      errors - The errors.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasErrors

      public boolean hasErrors()
      Does the result have any errors?
      Returns:
      Does the result have any errors?
    • firstError

      public ParseError firstError()
      Returns:
      The first error, or null if none.