Class OneOfN

    • Field Detail

      • choice

        protected final int choice
      • value

        protected final Object value
    • Method Detail

      • getChoice

        public int getChoice()
        Returns:
        The 0-based index representing the case for which a value is present.
      • 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.
      • hashCode

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

        protected final boolean is​(int choice)
        Parameters:
        choice - Index of the case to check.
        Returns:
        Whether a value is present for the given case.
      • 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.