java.util.stream.IntStream.empty()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中java.util.stream.IntStream.empty()方法的一些代码示例,展示了IntStream.empty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IntStream.empty()方法的具体详情如下:
包路径:java.util.stream.IntStream
类名称:IntStream
方法名:empty

IntStream.empty介绍

[英]Returns an empty sequential IntStream.
[中]返回一个空的顺序IntStream。

代码示例

代码示例来源:origin: google/guava

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: speedment/speedment

private static IntStream empty() {
  return IntStream.empty();
}

代码示例来源:origin: prestodb/presto

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: google/j2objc

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: wildfly/wildfly

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: apache/flink

private int extractMaxIndex(String key, String suffixPattern) {
  // extract index and property keys
  final String escapedKey = Pattern.quote(key);
  final Pattern pattern = Pattern.compile(escapedKey + "\\.(\\d+)" + suffixPattern);
  final IntStream indexes = properties.keySet().stream()
    .flatMapToInt(k -> {
      final Matcher matcher = pattern.matcher(k);
      if (matcher.find()) {
        return IntStream.of(Integer.valueOf(matcher.group(1)));
      }
      return IntStream.empty();
    });
  // determine max index
  return indexes.max().orElse(-1);
}

代码示例来源:origin: neo4j/neo4j

@SuppressWarnings( "unchecked" )
public static IntStream toBooleanStream( Object list )
{
  if ( list == null )
  {
    return IntStream.empty();
  }
  else if ( list instanceof SequenceValue )
  {
    throw new IllegalArgumentException( "Need to implement support for SequenceValue in CompiledConversionUtils.toBooleanStream" );
  }
  else if ( list instanceof List )
  {
    return ((List) list).stream().mapToInt( n -> ((Number) n).intValue() );
  }
  else if ( Object[].class.isAssignableFrom( list.getClass() ) )
  {
    return Arrays.stream( (Object[]) list ).mapToInt( n -> ((Number) n).intValue() );
  }
  else if ( list instanceof boolean[] )
  {
    boolean[] array = (boolean[]) list;
    return IntStream.range( 0, array.length ).map( i -> (array[i]) ? 1 : 0 );
  }
  throw new IllegalArgumentException( format( "Can not be converted to stream: %s", list.getClass().getName() ) );
}

代码示例来源:origin: speedment/speedment

@Override
  public TS build(boolean parallel) {
    if (Stream.class.equals(streamType)) {
      @SuppressWarnings("unchecked")
      final TS result = (TS) Stream.empty();
      return result;
    } else if (IntStream.class.equals(streamType)) {
      @SuppressWarnings("unchecked")
      final TS result = (TS) IntStream.empty();
      return result;
    } else if (LongStream.class.equals(streamType)) {
      @SuppressWarnings("unchecked")
      final TS result = (TS) LongStream.empty();
      return result;
    } else if (DoubleStream.class.equals(streamType)) {
      @SuppressWarnings("unchecked")
      final TS result = (TS) DoubleStream.empty();
      return result;
    } else {
      throw new UnsupportedOperationException(
        "Unknown stream type '" + streamType.getName() + "'."
      );
    }
  }
}

代码示例来源:origin: google/guava

public void testConcat_intStream() {
 assertThat(
     Streams.concat(IntStream.of(1), IntStream.of(2), IntStream.empty(), IntStream.of(3, 4)))
   .containsExactly(1, 2, 3, 4)
   .inOrder();
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Extract the lines of all the locations in the specified component. All the flows and secondary locations
 * are taken into account. The lines present in multiple flows and locations are kept
 * duplicated. Ordering of results is not guaranteed.
 * <p>
 * TODO should be a method of DefaultIssue, as soon as it's no
 * longer in sonar-core and can access sonar-db-dao.
 */
public static IntStream allLinesFor(DefaultIssue issue, String componentId) {
 DbIssues.Locations locations = issue.getLocations();
 if (locations == null) {
  return IntStream.empty();
 }
 Stream<DbCommons.TextRange> textRanges = Stream.concat(
  locations.hasTextRange() ? Stream.of(locations.getTextRange()) : Stream.empty(),
  locations.getFlowList().stream()
   .flatMap(f -> f.getLocationList().stream())
   .filter(l -> Objects.equals(componentIdOf(issue, l), componentId))
   .map(DbIssues.Location::getTextRange));
 return textRanges.flatMapToInt(range -> IntStream.rangeClosed(range.getStartLine(), range.getEndLine()));
}

代码示例来源:origin: google/guava

public void testCopyOf_stream() {
 assertThat(ImmutableIntArray.copyOf(IntStream.empty())).isSameAs(ImmutableIntArray.of());
 assertThat(ImmutableIntArray.copyOf(IntStream.of(0, 1, 3)).asList())
   .containsExactly(0, 1, 3)
   .inOrder();
}

代码示例来源:origin: Mojang/DataFixerUpper

return outOps.createIntList(inOps.getIntStream(input).orElse(IntStream.empty()));

代码示例来源:origin: poetix/protonpack

/**
 * Converts nullable int array into an empty stream, and non-null array into a stream.
 * @param nullable The nullable array to convert.
 * @return A stream of zero or more values.
 */
public static IntStream ofNullable(int[] nullable) {
  return null == nullable ? IntStream.empty() : Arrays.stream(nullable);
}

代码示例来源:origin: com.codepoetics/protonpack

/**
 * Converts nullable int array into an empty stream, and non-null array into a stream.
 * @param nullable The nullable array to convert.
 * @return A stream of zero or more values.
 */
public static IntStream ofNullable(int[] nullable) {
  return null == nullable ? IntStream.empty() : Arrays.stream(nullable);
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: org.weakref/jmxutils

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: martint/jmxutils

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: com.facebook.presto/presto-jdbc

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: org.apache.hbase.thirdparty/hbase-shaded-miscellaneous

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

代码示例来源:origin: org.apache.ratis/ratis-proto-shaded

/**
 * If a value is present in {@code optional}, returns a stream containing only that element,
 * otherwise returns an empty stream.
 *
 * <p><b>Java 9 users:</b> use {@code optional.stream()} instead.
 */
public static IntStream stream(OptionalInt optional) {
 return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty();
}

相关文章