Class OperatorSingle<T>

java.lang.Object
rx.internal.operators.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 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 Details

    • hasDefaultValue

      private final boolean hasDefaultValue
    • defaultValue

      private final T defaultValue
  • Constructor Details

    • OperatorSingle

      OperatorSingle()
    • OperatorSingle

      public OperatorSingle(T defaultValue)
    • OperatorSingle

      private OperatorSingle(boolean hasDefaultValue, T defaultValue)
  • Method Details

    • 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.
    • call

      public Subscriber<? super T> call(Subscriber<? super T> child)
      Specified by:
      call in interface Func1<Subscriber<? super T>,Subscriber<? super T>>