use of java.util.stream.DoubleStream in project junit5 by junit-team.
the class CollectionUtilsTests method toStreamWithDoubleStream.
@SuppressWarnings("unchecked")
@Test
void toStreamWithDoubleStream() {
DoubleStream input = DoubleStream.of(42.23);
Stream<Double> result = (Stream<Double>) CollectionUtils.toStream(input);
assertThat(result).containsExactly(42.23);
}
use of java.util.stream.DoubleStream in project keycloak by keycloak.
the class ClosingIntStream method asDoubleStream.
@Override
public DoubleStream asDoubleStream() {
DoubleStream result = delegate.asDoubleStream();
close();
return result;
}
use of java.util.stream.DoubleStream in project KursJava by SamouczekProgramisty.
the class StreamCreation method main.
public static void main(String[] args) throws FileNotFoundException {
Stream<Integer> stream1 = new LinkedList<Integer>().stream();
Stream<Integer> stream2 = Arrays.stream(new Integer[] {});
Stream<String> stream3 = Pattern.compile(".").splitAsStream("some longer sentence");
DoubleStream doubles = DoubleStream.of(1, 2, 3);
IntStream ints = IntStream.range(0, 123);
LongStream longs = LongStream.generate(() -> 1L);
DoubleStream randomDoubles = new Random().doubles();
IntStream randomInts = new Random().ints();
LongStream randomLongs = new Random().longs();
Stream.empty();
try (Stream<String> lines = new BufferedReader(new FileReader("file.txt")).lines()) {
//
}
}
use of java.util.stream.DoubleStream in project tutorials by eugenp.
the class GuavaStreamsUnitTest method createStreamsWithOptionalDouble.
@Test
public void createStreamsWithOptionalDouble() {
DoubleStream streamFromOptionalDouble = Streams.stream(OptionalDouble.of(1.0));
// Assert.assertNotNull(streamFromOptionalDouble);
assertEquals(streamFromOptionalDouble.count(), 1);
}
use of java.util.stream.DoubleStream in project tutorials by eugenp.
the class StreamsUtility method main.
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
// Using Collection
Stream<Integer> streamFromCollection = Streams.stream(numbers);
// Using Iterator
Stream<Integer> streamFromIterator = Streams.stream(numbers.iterator());
// Using Iterable
Stream<Integer> streamFromIterable = Streams.stream((Iterable<Integer>) numbers);
// Using Optional
Stream<Integer> streamFromOptional = Streams.stream(Optional.of(1));
// Using OptionalLong to LongStream
LongStream streamFromOptionalLong = Streams.stream(OptionalLong.of(1));
// Using OptionalInt to IntStream
IntStream streamFromOptionalInt = Streams.stream(OptionalInt.of(1));
// Using OptionalDouble to DoubleStream
DoubleStream streamFromOptionalDouble = Streams.stream(OptionalDouble.of(1.0));
Stream<Integer> concatenatedStreams = Streams.concat(streamFromCollection, streamFromIterable, streamFromIterator);
List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
// This will return 10
Optional<Integer> lastItem = Streams.findLast(integers.stream());
Streams.zip(Stream.of("candy", "chocolate", "bar"), Stream.of("$1", "$2", "$3"), (arg1, arg2) -> arg1 + ":" + arg2);
}
Aggregations