本文整理了Java中java.util.stream.IntStream.allMatch()
方法的一些代码示例,展示了IntStream.allMatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IntStream.allMatch()
方法的具体详情如下:
包路径:java.util.stream.IntStream
类名称:IntStream
方法名:allMatch
[英]Returns whether all 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: RichardWarburton/java-8-lambdas-exercises
private boolean isPrime(int number) {
return IntStream.range(2, number)
.allMatch(x -> (number % x) != 0);
}
// END parallel_functional
代码示例来源:origin: RichardWarburton/java-8-lambdas-exercises
private boolean isPrime(int number) {
return IntStream.range(2, number)
.allMatch(x -> (number % x) != 0);
}
// END functional
代码示例来源:origin: prestodb/presto
public PageChannelSelector(int... channels)
{
checkArgument(IntStream.of(channels).allMatch(channel -> channel >= 0), "channels must be positive");
this.channels = requireNonNull(channels, "channels is null").clone();
}
代码示例来源:origin: biezhi/30-seconds-of-java8
public static boolean isNumeric(final String input) {
if (input == null || input.isEmpty()) {
return false;
}
return IntStream.range(0, input.length())
.allMatch(i -> Character.isDigit(input.charAt(i)));
}
代码示例来源:origin: org.assertj/assertj-core
private boolean strictlyContainsWhitespaces(CharSequence actual) {
return actual.chars().allMatch(Character::isWhitespace);
}
代码示例来源:origin: speedment/speedment
@Override
public Boolean execute() {
try (final IntStream stream = buildPrevious()) {
return stream.allMatch(predicate);
}
}
}
代码示例来源:origin: kiegroup/jbpm
public static boolean isNumeric(String dateTimeStr) {
if (dateTimeStr != null) {
return dateTimeStr.chars().allMatch(Character::isDigit);
}
return false;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Add a single object into the script context.
*
* @param key the name in the context this object is to stored under.
* @param bean the object to be stored in the script context.
*/
public void addBean(String key, Object bean) {
if (!key.isEmpty() && Character.isJavaIdentifierStart(key.charAt(0))
&& key.chars().skip(1).allMatch(Character::isJavaIdentifierPart)) {
beans.put(key, bean);
}
}
代码示例来源:origin: speedment/speedment
default boolean allMatch(IntPipeline pipeline, IntPredicate predicate) {
requireNonNull(pipeline);
requireNonNull(predicate);
return optimize(pipeline).getAsIntStream().allMatch(predicate);
}
代码示例来源:origin: speedment/speedment
@Override
public boolean allMatch(IntPredicate predicate) {
return finallyClose(() -> stream().allMatch(predicate));
}
代码示例来源:origin: spring-projects/spring-security
private static boolean isErrorUriValid(String errorUri) {
return errorUri == null ||
errorUri.chars().allMatch(c ->
c == 0x21 ||
withinTheRangeOf(c, 0x23, 0x5B) ||
withinTheRangeOf(c, 0x5D, 0x7E));
}
代码示例来源:origin: spring-projects/spring-security
private static boolean isDescriptionValid(String description) {
return description == null ||
description.chars().allMatch(c ->
withinTheRangeOf(c, 0x20, 0x21) ||
withinTheRangeOf(c, 0x23, 0x5B) ||
withinTheRangeOf(c, 0x5D, 0x7E));
}
代码示例来源:origin: spring-projects/spring-security
private static boolean isErrorCodeValid(String errorCode) {
return errorCode.chars().allMatch(c ->
withinTheRangeOf(c, 0x20, 0x21) ||
withinTheRangeOf(c, 0x23, 0x5B) ||
withinTheRangeOf(c, 0x5D, 0x7E));
}
代码示例来源:origin: spring-projects/spring-security
private static boolean validateScope(String scope) {
return scope == null ||
scope.chars().allMatch(c ->
withinTheRangeOf(c, 0x21, 0x21) ||
withinTheRangeOf(c, 0x23, 0x5B) ||
withinTheRangeOf(c, 0x5D, 0x7E));
}
代码示例来源:origin: spring-projects/spring-security
private static boolean isScopeValid(String scope) {
return scope == null ||
scope.chars().allMatch(c ->
withinTheRangeOf(c, 0x20, 0x21) ||
withinTheRangeOf(c, 0x23, 0x5B) ||
withinTheRangeOf(c, 0x5D, 0x7E));
}
代码示例来源: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 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 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: 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();
}
内容来源于网络,如有侵权,请联系作者删除!