Class OneOfN.Just<T1>

java.lang.Object
de.xima.fc.api.rest.pub.client.generic.OneOfN
de.xima.fc.api.rest.pub.client.generic.OneOfN.Just<T1>
Type Parameters:
T1 - Type of the value for the first case.
Enclosing class:
OneOfN

public static final class OneOfN.Just<T1> extends OneOfN
Emulates a sum type consisting of 1 cases.
  • Method Details

    • getValue

      public T1 getValue()
      Description copied from class: OneOfN
      Checks which case applies and returns the value for that case. You need to cast it yourself to the required type.
      Overrides:
      getValue in class OneOfN
      Returns:
      The value of this sum type.
    • match

      public <R> R match(Function<T1,R> first)
      Performs a case match on this sum type by invoking the mapping function for the matching case with the value of this sum type and returning the result.
      Type Parameters:
      R - Type of the result returned by each mapping function.
      Parameters:
      first - Mapping function for the first case.
      Returns:
      The value returned by the mapping function for the matching case.
    • match

      public <R> R match(R defaultValue, OneOfN.JustMatcher<R,T1> matcher)
      Performs a case match on this sum type by invoking the mapping function for the matching case with the value of this sum type and returning the result.
      Type Parameters:
      R - Type of the result returned by each mapping function.
      Parameters:
      defaultValue - Value returned when the given matcher has no matching case.
      matcher - Matcher object for each case.
      Returns:
      The value returned by the mapping function for the matching case.
    • selectFirst

      public Optional<T1> selectFirst()
      Returns:
      The value of the first case, if a value exists for that case.
    • isFirst

      public boolean isFirst()
      Returns:
      Whether a value for the first case is present.
    • first

      public static <T1> OneOfN.Just<T1> first(T1 first)
      Parameters:
      first - The value for the first case.
      Returns:
      A new sum type with the value for the first case.