lv.eparaksts.validation

## Class ValidationResult

- java.lang.Object
- - lv.eparaksts.validation.ValidationResult

- Direct Known Subclasses:
    CertificateValidationResult, SignatureValidationResult

      public class ValidationResult
      extends Object

  A `ValidationResult` is a tree structured data set of an object validation result.
  See Also:
    `Validatable.validate()`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected LinkedList<ValidationResult>` | `resultList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValidationResult(ValidationType type)` Creates `ValidationResult` of the given type.
    `ValidationResult(ValidationType type, String id, String description, Date validationDate)` Creates `ValidationResult` of the given type.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ValidationResult` | `addResult(ValidationResult result)` Adds a child validation result of the given type to the result.
    `ValidationResult` | `addResult(ValidationType type)` Creates and adds a new child validation result of the given type to the result.
    `void` | `checkFailed(String reason)` Adds reason message to the result and sets the result validationStatus to `ValidationStatus.FAILED`.
    `void` | `checkNotChecked(String reason)` Adds reason message to the result and sets the result status to `ValidationStatus.UNCHECKED`.
    `void` | `checkPassed()` Sets the result status to `ValidationStatus.PASSED` if status is `null`.
    `String` | `getDescription()` Returns description of the validation result.
    `String` | `getId()` Returns id of the result.
    `String[]` | `getReasons()` Returns an array of failure reason messages of the result.
    `ValidationResult[]` | `getResults()` Returns an array of child results contained by the result.
    `SignatureValidationResult` | `getSignatureResult(String signatureId)` Finds and returns signature's validation result by the specified signature ID.
    `ValidationStatus` | `getStatus()` Returns status of the validation result.
    `ValidationType` | `getType()` Returns type of the validation result.
    `Date` | `getValidationDate()` Returns the time when the validation was performed.
    `void` | `setDescription(String description)` Sets description of the validation result.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### resultList

          protected final LinkedList<ValidationResult> resultList

  - ### Constructor Detail

    - #### ValidationResult

          public ValidationResult(ValidationType type)

      Creates `ValidationResult` of the given type.
      Parameters:
        `type` - type of the result.

    - #### ValidationResult

          public ValidationResult(ValidationType type,
                                  String id,
                                  String description,
                                  Date validationDate)

      Creates `ValidationResult` of the given type.
      Parameters:
        `type` - type of the result.
        `id` - identifier of the validation result.
        `description` - description of the validation result.
        `validationDate` - validation time.

  - ### Method Detail

    - #### addResult

          public ValidationResult addResult(ValidationType type)

      Creates and adds a new child validation result of the given type to the result.
      Parameters:
        `type` - type of the result.
      Returns:
        newly created validation result.

    - #### addResult

          public ValidationResult addResult(ValidationResult result)

      Adds a child validation result of the given type to the result.
      Parameters:
        `result` - child result.
      Returns:
        the given validation result instance for convenience.

    - #### getType

          public ValidationType getType()

      Returns type of the validation result.
      Returns:
        type of the result.

    - #### getStatus

          public ValidationStatus getStatus()

      Returns status of the validation result.
      Returns:
        status of the result.

    - #### getSignatureResult

          public SignatureValidationResult getSignatureResult(String signatureId)

      Finds and returns signature's validation result by the specified signature ID.
      Parameters:
        `signatureId` - Signature's ID.
      Returns:
        the result or `null` if result by signature ID was not found.

    - #### checkPassed

          public void checkPassed()

      Sets the result status to `ValidationStatus.PASSED` if status is `null`.

    - #### checkNotChecked

          public void checkNotChecked(String reason)

      Adds reason message to the result and sets the result status to `ValidationStatus.UNCHECKED`.
      Parameters:
        `reason` - reason message.

    - #### checkFailed

          public void checkFailed(String reason)

      Adds reason message to the result and sets the result validationStatus to `ValidationStatus.FAILED`.
      Parameters:
        `reason` - reason message.

    - #### getId

          public String getId()

      Returns id of the result.
      Returns:
        result id.

    - #### getDescription

          public String getDescription()

      Returns description of the validation result.
      Returns:
        description of the validation result.

    - #### setDescription

          public void setDescription(String description)

      Sets description of the validation result.
      Parameters:
        `description` - description of the validation result.

    - #### getValidationDate

          public Date getValidationDate()

      Returns the time when the validation was performed.
      Returns:
        validation time.

    - #### getResults

          public ValidationResult[] getResults()

      Returns an array of child results contained by the result.
      Returns:
        an array of child results.

    - #### getReasons

          public String[] getReasons()

      Returns an array of failure reason messages of the result.
      Returns:
        an array of failure reason messages.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright VAS Latvijas Valsts radio un televizijas centrs / Developed by SIA EUSO