Package net.sf.saxon.om

## Class One<T extends Item>

- java.lang.Object
- - net.sf.saxon.om.ZeroOrOne<T>
  - - net.sf.saxon.om.One<T>

- 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 Summary

    Constructors
    Constructor | Description
    --- | ---
    `One​(T item)` | Create an instance of the class

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static One<BooleanValue>` | `bool​(boolean value)` | Convenience function to create a singleton boolean value
    `static One<DoubleValue>` | `dbl​(double value)` | Convenience function to create a singleton double value
    `static One<IntegerValue>` | `integer​(long value)` | Convenience function to create a singleton integer value
    `ConstrainedIterator<T>` | `iterate()` | Return an iterator over this value.
    `static One<StringValue>` | `string​(java.lang.String value)` | Convenience function to create a singleton string value

    - ### Methods inherited from class net.sf.saxon.om.ZeroOrOne

      `effectiveBooleanValue, empty, getLength, getStringValue, getStringValueCS, head, itemAt, reduce, subsequence, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.om.GroundedValue

      `asIterable, concatenate, containsNode, materialize, toShortString`

    - ### Methods inherited from interface net.sf.saxon.om.Sequence

      `makeRepeatable`

- - ### Constructor Detail

    - #### One

          public One​(T item)

      Create an instance of the class
      Parameters:
        `item` - The single item to be contained in the sequence. Must not be null.
      Throws:
        `java.lang.NullPointerException` - if item is null.

  - ### Method Detail

    - #### iterate

          public ConstrainedIterator<T> iterate()

      Return an iterator over this value.
      Specified by:
        `iterate` in interface `GroundedValue`
      Specified by:
        `iterate` in interface `Sequence`
      Overrides:
        `iterate` in class `ZeroOrOne<T extends Item>`
      Returns:
        an iterator (meaning a Saxon `SequenceIterator` rather than a Java `Iterator`) over all the items in this Sequence.

    - #### bool

          public static One<BooleanValue> bool​(boolean value)

      Convenience function to create a singleton boolean value
      Parameters:
        `value` - the boolean value
      Returns:
        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
      Parameters:
        `value` - the string value.. If null, the result will represent a zero-length string
      Returns:
        the string value wrapped as a One<StringValue>

    - #### integer

          public static One<IntegerValue> integer​(long value)

      Convenience function to create a singleton integer value
      Parameters:
        `value` - the integer value
      Returns:
        the integer value wrapped as a One<IntegerValue>

    - #### dbl

          public static One<DoubleValue> dbl​(double value)

      Convenience function to create a singleton double value
      Parameters:
        `value` - the double value
      Returns:
        the double value wrapped as a One<DoubleValue>