本文整理汇总了Java中java.util.function.LongPredicate.test方法的典型用法代码示例。如果您正苦于以下问题:Java LongPredicate.test方法的具体用法?Java LongPredicate.test怎么用?Java LongPredicate.test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.function.LongPredicate
的用法示例。
在下文中一共展示了LongPredicate.test方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
public final LongStream filter(LongPredicate predicate) {
Objects.requireNonNull(predicate);
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SIZED) {
@Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
@Override
public void begin(long size) {
downstream.begin(-1);
}
@Override
public void accept(long t) {
if (predicate.test(t))
downstream.accept(t);
}
};
}
};
}
示例2: makeLong
import java.util.function.LongPredicate; //导入方法依赖的package包/类
/**
* Constructs a quantified predicate matcher for a {@code LongStream}.
*
* @param predicate the {@code Predicate} to apply to stream elements
* @param matchKind the kind of quantified match (all, any, none)
* @return a {@code TerminalOp} implementing the desired quantified match
* criteria
*/
public static TerminalOp<Long, Boolean> makeLong(LongPredicate predicate,
MatchKind matchKind) {
Objects.requireNonNull(predicate);
Objects.requireNonNull(matchKind);
class MatchSink extends BooleanTerminalSink<Long> implements Sink.OfLong {
MatchSink() {
super(matchKind);
}
@Override
public void accept(long t) {
if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
stop = true;
value = matchKind.shortCircuitResult;
}
}
}
return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, MatchSink::new);
}
示例3: allMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean allMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) && predicate.test(this.y());
}
示例4: anyMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean anyMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) || predicate.test(this.y());
}
示例5: allMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean allMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) && predicate.test(this.y()) && predicate.test(this.z()) && predicate.test(this.w());
}
示例6: anyMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean anyMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) || predicate.test(this.y()) || predicate.test(this.z()) || predicate.test(this.w());
}
示例7: allMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean allMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) && predicate.test(this.y()) && predicate.test(this.z());
}
示例8: anyMatch
import java.util.function.LongPredicate; //导入方法依赖的package包/类
@Override
default boolean anyMatch(@NonNull final LongPredicate predicate) {
return predicate.test(this.x()) || predicate.test(this.y()) || predicate.test(this.z());
}
示例9: satisfies
import java.util.function.LongPredicate; //导入方法依赖的package包/类
/**
* Tests the subject with the given predicate. Note that any {@link Throwable} thrown
* during the testing of the predicate is not handled and will be thrown instead
* of the usual throwable for this verifiable instance.
*
* @param expected the {@link LongPredicate} to use to test the subject.
* May not be null.
* @return the subject if it satisfies the predicate.
* @throws X if the subject does not satisfy the predicate.
* @throws NullPointerException if expected is null.
*/
public long satisfies(LongPredicate expected) throws X {
if (null == expected) {
throw new NullPointerException(ValidityUtils.nullArgumentMessage("expected"));
}
if (!expected.test(subject)) {
fail(ValidityUtils.describe(expected));
}
return subject;
}