Class JPropertySuccess<A>

java.lang.Object
com.io7m.jproperties.monad.JPropertySuccess<A>
Type Parameters:
A - The type of result values
All Implemented Interfaces:
JPropertyParseMonadType<A>, JPropertyParseMonadType.JPropertySuccessType<A>

public final class JPropertySuccess<A> extends Object implements JPropertyParseMonadType.JPropertySuccessType<A>
A result indicating success.
  • Method Details

    • result

      public A result()
      Specified by:
      result in interface JPropertyParseMonadType.JPropertySuccessType<A>
      Returns:
      The result of parsing
    • warnings

      public List<JPropertyWarning> warnings()
      Specified by:
      warnings in interface JPropertyParseMonadType<A>
      Returns:
      The accumulated warnings
    • errors

      public List<JPropertyError> errors()
      Specified by:
      errors in interface JPropertyParseMonadType<A>
      Returns:
      The accumulated errors
    • withResult

      public final JPropertySuccess<A> withResult(A value)
      Copy the current immutable object by setting a value for the result attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for result
      Returns:
      A modified copy of the this object
    • withWarnings

      public final JPropertySuccess<A> withWarnings(JPropertyWarning... elements)
      Copy the current immutable object with elements that replace the content of warnings.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withWarnings

      public final JPropertySuccess<A> withWarnings(Iterable<? extends JPropertyWarning> elements)
      Copy the current immutable object with elements that replace the content of warnings. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of warnings elements to set
      Returns:
      A modified copy of this object
    • withErrors

      public final JPropertySuccess<A> withErrors(JPropertyError... elements)
      Copy the current immutable object with elements that replace the content of errors.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withErrors

      public final JPropertySuccess<A> withErrors(Iterable<? extends JPropertyError> elements)
      Copy the current immutable object with elements that replace the content of errors. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of errors elements to set
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of JPropertySuccess that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: result, warnings, errors.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value JPropertySuccess with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static <A> JPropertySuccess<A> copyOf(JPropertyParseMonadType.JPropertySuccessType<A> instance)
      Creates an immutable copy of a JPropertyParseMonadType.JPropertySuccessType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Type Parameters:
      A - generic parameter A
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable JPropertySuccess instance
    • builder

      public static <A> JPropertySuccess.Builder<A> builder()
      Creates a builder for JPropertySuccess.
      Type Parameters:
      A - generic parameter A
      Returns:
      A new JPropertySuccess builder