本文整理汇总了Java中java.util.stream.LongStream.of方法的典型用法代码示例。如果您正苦于以下问题:Java LongStream.of方法的具体用法?Java LongStream.of怎么用?Java LongStream.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.stream.LongStream
的用法示例。
在下文中一共展示了LongStream.of方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arrayToStream
import java.util.stream.LongStream; //导入方法依赖的package包/类
public static Object arrayToStream(final Object array) {
if (array instanceof int[]) {
return IntStream.of((int[])array);
} else if (array instanceof long[]) {
return LongStream.of((long[])array);
} else if (array instanceof double[]) {
return DoubleStream.of((double[])array);
} else if (array instanceof Object[]) {
return Stream.of((Object[])array);
} else {
throw new IllegalArgumentException();
}
}
示例2: longProvider
import java.util.stream.LongStream; //导入方法依赖的package包/类
static LongStream longProvider() {
return LongStream.of(4L, 5L);
}
示例3: stream
import java.util.stream.LongStream; //导入方法依赖的package包/类
@NonNull
@Override
default LongStream stream() {
return LongStream.of(this.x(), this.y());
}
示例4: stream
import java.util.stream.LongStream; //导入方法依赖的package包/类
@NonNull
@Override
default LongStream stream() {
return LongStream.of(this.x(), this.y(), this.z(), this.w());
}
示例5: stream
import java.util.stream.LongStream; //导入方法依赖的package包/类
@NonNull
@Override
default LongStream stream() {
return LongStream.of(this.x(), this.y(), this.z());
}
示例6: stream
import java.util.stream.LongStream; //导入方法依赖的package包/类
/**
* If a value is present, returns a sequential {@link LongStream} containing
* only that value, otherwise returns an empty {@code LongStream}.
*
* @apiNote
* This method can be used to transform a {@code Stream} of optional longs
* to an {@code LongStream} of present longs:
* <pre>{@code
* Stream<OptionalLong> os = ..
* LongStream s = os.flatMapToLong(OptionalLong::stream)
* }</pre>
*
* @return the optional value as an {@code LongStream}
* @since 9
*/
public LongStream stream() {
if (isPresent) {
return LongStream.of(value);
} else {
return LongStream.empty();
}
}
示例7: stream
import java.util.stream.LongStream; //导入方法依赖的package包/类
/**
* 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 LongStream stream(OptionalLong optional) {
return optional.isPresent() ? LongStream.of(optional.getAsLong()) : LongStream.empty();
}