Package rx.internal.operators
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 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OperatorSingle.Holder
(package private) static class
OperatorSingle.ParentSubscriber<T>
-
Field Summary
Fields Modifier and Type Field Description private T
defaultValue
private boolean
hasDefaultValue
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
OperatorSingle()
private
OperatorSingle(boolean hasDefaultValue, T defaultValue)
OperatorSingle(T defaultValue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Subscriber<? super T>
call(Subscriber<? super T> child)
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.
-
-
-
Field Detail
-
hasDefaultValue
private final boolean hasDefaultValue
-
defaultValue
private final 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.
-
call
public Subscriber<? super T> call(Subscriber<? super T> child)
- Specified by:
call
in interfaceFunc1<Subscriber<? super T>,Subscriber<? super T>>
-
-