Record Class ParseResult<M extends PackageManifest>

java.lang.Object
java.lang.Record
dev.jcputney.elearning.parser.api.ParseResult<M>
Type Parameters:
M - The type of package manifest associated with the module
Record Components:
validation - The validation result containing any errors or warnings found
metadata - The extracted module metadata (always present, even if validation failed)

public record ParseResult<M extends PackageManifest>(ValidationResult validation, ModuleMetadata<M extends PackageManifest> metadata) extends Record
Result of parsing and validating an eLearning module. Contains both the validation result and the extracted metadata.

This record is returned by ModuleParser.parseAndValidate() to provide both validation feedback and parsed content in a single operation, eliminating the need to parse the manifest twice.

  • Constructor Details

    • ParseResult

      public ParseResult(ValidationResult validation, ModuleMetadata<M> metadata)
      Creates an instance of a ParseResult record class.
      Parameters:
      validation - the value for the validation record component
      metadata - the value for the metadata record component
  • Method Details

    • isValid

      public boolean isValid()
      Checks if the module passed validation without errors. Warnings are not considered failures.
      Returns:
      true if validation passed (no errors), false otherwise
    • hasErrors

      public boolean hasErrors()
      Checks if the module has any validation errors.
      Returns:
      true if there are validation errors, false otherwise
    • hasWarnings

      public boolean hasWarnings()
      Checks if the module has any validation warnings.
      Returns:
      true if there are validation warnings, false otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • validation

      public ValidationResult validation()
      Returns the value of the validation record component.
      Returns:
      the value of the validation record component
    • metadata

      public ModuleMetadata<M> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component