Class OperatorSingle<T>

  • Type Parameters:
    T - the value type
    All Implemented Interfaces:
    Func1<Subscriber<? super T>,​Subscriber<? super T>>, Function, Observable.Operator<T,​T>

    public final class OperatorSingle<T>
    extends java.lang.Object
    implements Observable.Operator<T,​T>
    If the Observable completes after emitting a single item that matches a predicate, return an Observable containing that item. If it emits more than one such item or no item, throw an IllegalArgumentException.
    • Field Detail

      • hasDefaultValue

        private final boolean hasDefaultValue
      • defaultValue

        private final T defaultValue
    • Constructor Detail

      • OperatorSingle

        OperatorSingle()
      • OperatorSingle

        public OperatorSingle​(T defaultValue)
      • OperatorSingle

        private OperatorSingle​(boolean hasDefaultValue,
                               T defaultValue)
    • Method Detail

      • instance

        public static <T> OperatorSingle<T> instance()
        Returns a singleton instance of OperatorSingle (if the stream is empty or has more than one element an error will be emitted) that is cast to the generic type.
        Type Parameters:
        T - the value type
        Returns:
        a singleton instance of an Operator that will emit a single value only unless the stream has zero or more than one element in which case it will emit an error.