本文整理汇总了Java中rx.functions.Functions.identity方法的典型用法代码示例。如果您正苦于以下问题:Java Functions.identity方法的具体用法?Java Functions.identity怎么用?Java Functions.identity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.functions.Functions
的用法示例。
在下文中一共展示了Functions.identity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EmptyEvictionPolicy
import rx.functions.Functions; //导入方法依赖的package包/类
/**
* Creates an unbounded replay subject with the bounded-implementation for testing purposes.
* <p>
* This variant behaves like the regular unbounded {@code ReplaySubject} created via {@link #create()} but
* uses the structures of the bounded-implementation. This is by no means intended for the replacement of
* the original, array-backed and unbounded {@code ReplaySubject} due to the additional overhead of the
* linked-list based internal buffer. The sole purpose is to allow testing and reasoning about the behavior
* of the bounded implementations without the interference of the eviction policies.
*
* @param <T>
* the type of items observed and emitted by the Subject
* @return the created subject
*/
/* public */ static <T> ReplaySubject<T> createUnbounded() {
final BoundedState<T> state = new BoundedState<T>(
new EmptyEvictionPolicy(),
Functions.identity(),
Functions.identity()
);
return createWithState(state, new DefaultOnAdd<T>(state));
}
示例2: createWithSize
import rx.functions.Functions; //导入方法依赖的package包/类
/**
* Creates a size-bounded replay subject.
* <p>
* In this setting, the {@code ReplaySubject} holds at most {@code size} items in its internal buffer and
* discards the oldest item.
* <p>
* When observers subscribe to a terminated {@code ReplaySubject}, they are guaranteed to see at most
* {@code size} {@code onNext} events followed by a termination event.
* <p>
* If an observer subscribes while the {@code ReplaySubject} is active, it will observe all items in the
* buffer at that point in time and each item observed afterwards, even if the buffer evicts items due to
* the size constraint in the mean time. In other words, once an Observer subscribes, it will receive items
* without gaps in the sequence.
*
* @param <T>
* the type of items observed and emitted by the Subject
* @param size
* the maximum number of buffered items
* @return the created subject
*/
public static <T> ReplaySubject<T> createWithSize(int size) {
final BoundedState<T> state = new BoundedState<T>(
new SizeEvictionPolicy(size),
Functions.identity(),
Functions.identity()
);
return createWithState(state, new DefaultOnAdd<T>(state));
}