Class ValidationContext

java.lang.Object
com.atlassian.bamboo.specs.api.validators.common.ValidationContext

public final class ValidationContext extends Object
This class helps to describe location of problems found by validators. Typical usage:
  • no context of an error:
    ValidationContext.empty()
  • a single element:
    ValidationContext.of("key")
  • a nested hierarchy:
    ValidationContext.of("Plan P").with("Stage 1").with("Job A").with("name")
  • Method Details

    • empty

      public static ValidationContext empty()
      Returns an empty context.
      Returns:
      ValidationContext
    • of

      public static ValidationContext of(@NotNull @NotNull String context)
      Returns a single-element context.
      Parameters:
      context - name
      Returns:
      ValidationContext
    • with

      public ValidationContext with(@NotNull @NotNull String context)
      Returns new instance of validation context with the context element appended to it.
      Parameters:
      context - name
      Returns:
      ValidationContext
    • isEmpty

      public boolean isEmpty()
      Returns true if context is empty.
      Returns:
      boolean
    • contains

      public boolean contains(String element)
      Returns true if context contains the given element.
      Returns:
      boolean
    • toString

      public String toString()
      Overrides:
      toString in class Object