Class One<T extends Item>

  • All Implemented Interfaces:
    GroundedValue, Sequence

    public class One<T extends Item>
    extends ZeroOrOne<T>
    A sequence containing exactly one item. The main use of this class is in declaring the expected arguments of reflexive method calls, where the use of One(T) rather than T emphasizes that the value must not be null/empty, and generates type-checking code to ensure that it is not empty.

    To extract the wrapped item, use ZeroOrOne.head().

    • Constructor Detail

      • One

        public One​(T item)
        Create an instance of the class
        item - The single item to be contained in the sequence. Must not be null.
        java.lang.NullPointerException - if item is null.
    • Method Detail

      • bool

        public static One<BooleanValue> bool​(boolean value)
        Convenience function to create a singleton boolean value
        value - the boolean value
        the boolean value wrapped as a One<BooleanValue>
      • string

        public static One<StringValue> string​(java.lang.String value)
        Convenience function to create a singleton string value
        value - the string value.. If null, the result will represent a zero-length string
        the string value wrapped as a One<StringValue>
      • integer

        public static One<IntegerValue> integer​(long value)
        Convenience function to create a singleton integer value
        value - the integer value
        the integer value wrapped as a One<IntegerValue>
      • dbl

        public static One<DoubleValue> dbl​(double value)
        Convenience function to create a singleton double value
        value - the double value
        the double value wrapped as a One<DoubleValue>