本文整理了Java中java.util.stream.IntStream.noneMatch()
方法的一些代码示例,展示了IntStream.noneMatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IntStream.noneMatch()
方法的具体详情如下:
包路径:java.util.stream.IntStream
类名称:IntStream
方法名:noneMatch
[英]Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.
This is a short-circuiting terminal operation.
[中]返回此流的元素是否与提供的谓词匹配。如果不需要确定结果,则不能对所有元素的谓词求值。如果流为空,则返回true,并且不计算谓词。
这是一个short-circuiting terminal operation。
代码示例来源:origin: prestodb/presto
private static boolean validateName(String name)
{
return name.chars().noneMatch(c -> c == '<' || c == '>' || c == ',');
}
代码示例来源:origin: prestodb/presto
private static boolean validateName(String name)
{
return name.chars().noneMatch(c -> c == '<' || c == '>' || c == ',');
}
代码示例来源:origin: speedment/speedment
@Override
public Boolean execute() {
try (final IntStream stream = buildPrevious()) {
return stream.noneMatch(predicate);
}
}
}
代码示例来源:origin: biezhi/30-seconds-of-java8
/**
* Filters out all values from an array for which the comparator function does not return true.
*
* @param first the first array
* @param second the second array
* @param comparator the comparator function
* @return the resulting array
*/
public static int[] differenceWith(int[] first, int[] second, IntBinaryOperator comparator) {
return Arrays.stream(first)
.filter(a ->
Arrays.stream(second)
.noneMatch(b -> comparator.applyAsInt(a, b) == 0)
).toArray();
}
代码示例来源:origin: speedment/speedment
default boolean noneMatch(IntPipeline pipeline, IntPredicate predicate) {
requireNonNull(pipeline);
requireNonNull(predicate);
return optimize(pipeline).getAsIntStream().noneMatch(predicate);
}
代码示例来源:origin: speedment/speedment
@Override
public boolean noneMatch(IntPredicate predicate) {
return finallyClose(() -> stream().noneMatch(predicate));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldAddPatternToExcludeLinesWithMess() throws Exception {
Path filePath = getResource("file-with-double-regexp-mess.txt");
fileMetadata.readMetadata(Files.newInputStream(filePath), UTF_8, filePath.toString(), regexpScanner);
assertThat(IntStream.rangeClosed(1, 20).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(21, 29).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(30, 37).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldExcludeLines() throws Exception {
Path filePath = getResource("file-with-double-regexp.txt");
fileMetadata.readMetadata(Files.newInputStream(filePath), UTF_8, filePath.toString(), regexpScanner);
assertThat(javaFile.isIgnoreAllIssues()).isFalse();
assertThat(IntStream.rangeClosed(1, 20).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(21, 25).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(26, 34).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldAddPatternToExcludeLinesWithWrongOrder() throws Exception {
Path filePath = getResource("file-with-double-regexp-wrong-order.txt");
fileMetadata.readMetadata(Files.newInputStream(filePath), UTF_8, filePath.toString(), regexpScanner);
assertThat(IntStream.rangeClosed(1, 24).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(25, 35).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldAddPatternToExcludeSeveralLineRanges() throws Exception {
Path filePath = getResource("file-with-double-regexp-twice.txt");
fileMetadata.readMetadata(Files.newInputStream(filePath), UTF_8, filePath.toString(), regexpScanner);
assertThat(javaFile.isIgnoreAllIssues()).isFalse();
assertThat(IntStream.rangeClosed(1, 20).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(21, 25).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(26, 28).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(29, 33).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldAddPatternToExcludeLinesTillTheEnd() throws Exception {
Path filePath = getResource("file-with-double-regexp-unfinished.txt");
fileMetadata.readMetadata(Files.newInputStream(filePath), UTF_8, filePath.toString(), regexpScanner);
assertThat(javaFile.isIgnoreAllIssues()).isFalse();
assertThat(IntStream.rangeClosed(1, 20).noneMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
assertThat(IntStream.rangeClosed(21, 34).allMatch(javaFile::isIgnoreAllIssuesOnLine)).isTrue();
}
代码示例来源:origin: shekhargulati/30-seconds-of-java
/**
* Filters out all values from an array for which the comparator function does not return true.
*
* @param first the first array
* @param second the second array
* @param comparator the comparator function
* @return the resulting array
*/
public static int[] differenceWith(int[] first, int[] second, IntBinaryOperator comparator) {
return Arrays.stream(first)
.filter(a ->
Arrays.stream(second)
.noneMatch(b -> comparator.applyAsInt(a, b) == 0)
).toArray();
}
代码示例来源:origin: org.apereo.cas/cas-server-support-spnego
/**
* Checks if is token ntlm.
*
* @param token the token
* @return true, if token ntlm
*/
private static boolean isTokenNtlm(final byte[] token) {
if (token == null || token.length < NTLM_TOKEN_MAX_LENGTH) {
return false;
}
return IntStream.range(0, NTLM_TOKEN_MAX_LENGTH).noneMatch(i -> NTLMSSP_SIGNATURE[i] != token[i]);
}
代码示例来源:origin: kousen/java_8_recipes
public static boolean isPrime(int num) {
int limit = (int) (Math.sqrt(num) + 1);
return num == 2 || num > 1 && IntStream.range(2, limit)
.noneMatch(divisor -> num % divisor == 0);
}
代码示例来源:origin: kousen/java_8_recipes
public boolean isPrime(int num) {
int limit = (int) (Math.sqrt(num) + 1);
return num == 2 || num > 1 && IntStream.range(2, limit)
.noneMatch(divisor -> num % divisor == 0);
}
代码示例来源:origin: com.facebook.presto/presto-spi
private static boolean validateName(String name)
{
return name.chars().noneMatch(c -> c == '<' || c == '>' || c == ',');
}
代码示例来源:origin: com.opentable.components/otj-kafka
boolean onRestoreEnd(TopicPartition topicPartition) {
final int partition = topicPartition.partition();
offset[partition] = end[partition];
return IntStream.range(0, offset.length)
.noneMatch(p -> offset[p] != end[p]);
}
代码示例来源:origin: org.scribble/scribble-cli
private static boolean validateModuleArg(String arg)
{
return arg.chars().noneMatch((i) ->
!Character.isLetterOrDigit(i) && i != '.' && i != File.separatorChar && i != ':' && i != '-' && i != '_'
&& i != '/'); // Hack? (cygwin)
}
代码示例来源:origin: com.speedment.runtime/runtime-core
default boolean noneMatch(IntPipeline pipeline, IntPredicate predicate) {
requireNonNull(pipeline);
requireNonNull(predicate);
return optimize(pipeline).getAsIntStream().noneMatch(predicate);
}
代码示例来源:origin: jenetics/jenetics
@Test
public void zeros() {
final BitChromosome c = BitChromosome.of(1000, 0.5);
final int zeros = (int)c.zeros().count();
assertEquals(zeros, c.length() - c.bitCount());
assertTrue(c.zeros().noneMatch(c::booleanValue));
}
内容来源于网络,如有侵权,请联系作者删除!