Class OneOfN

java.lang.Object
de.xima.fc.api.rest.pub.client.security.OneOfN
Direct Known Subclasses:
OneOfN.Either, OneOfN.Just, OneOfN.None, OneOfN.OneOf3, OneOfN.OneOf4, OneOfN.OneOf5

@Generated("de.xima.openapi.codegen.java_jaxrs.XimaJavaJaxrsGenerator") public abstract class OneOfN extends Object
Base class for emulating a sum type (also known as a discriminated union) of N elements.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Emulates a sum type consisting of 2 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
    static final class 
    Emulates a sum type consisting of 1 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
    static final class 
    Emulates a sum type consisting of 0 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
    static final class 
    Emulates a sum type consisting of 3 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
    static final class 
    Emulates a sum type consisting of 4 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
    static final class 
    Emulates a sum type consisting of 5 cases.
    static interface 
    A matcher object that contains a handler for each case and can be used to reduce a sum type to a single value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
    protected final Object
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
    Checks which case applies and returns the value for that case.
    int
     
    protected final boolean
    is(int choice)
     
    protected final Optional<Object>
    select(int choice)
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • choice

      protected final int choice
    • value

      protected final Object value
  • Method Details

    • getValue

      public Object getValue()
      Checks which case applies and returns the value for that case. You need to cast it yourself to the required type.
      Returns:
      The value of this sum type.
    • getChoice

      public int getChoice()
      Returns:
      The 0-based index representing the case for which a value is present.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • select

      protected final Optional<Object> select(int choice)
      Parameters:
      choice - Index of the case to get.
      Returns:
      The value of the given case, if present.
    • is

      protected final boolean is(int choice)
      Parameters:
      choice - Index of the case to check.
      Returns:
      Whether a value is presen for the given case.