java.util.stream.LongStream.Builder Java Examples
The following examples show how to use
java.util.stream.LongStream.Builder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkingDaysToDaysConverter.java From taskana with Apache License 2.0 | 6 votes |
public boolean isGermanHoliday(LocalDate date) { if (GERMAN_HOLIDAYS.contains(CustomHoliday.of(date.getDayOfMonth(), date.getMonthValue()))) { return true; } // Easter holidays Good Friday, Easter Monday, Ascension Day, Whit Monday. long diffFromEasterSunday = DAYS.between(easterCalculator.getEasterSunday(date.getYear()), date); Builder builder = LongStream.builder() .add(OFFSET_GOOD_FRIDAY) .add(OFFSET_EASTER_MONDAY) .add(OFFSET_ASCENSION_DAY) .add(OFFSET_WHIT_MONDAY); if (corpusChristiEnabled) { builder.add(OFFSET_CORPUS_CHRISTI); } return builder.build().anyMatch(c -> c == diffFromEasterSunday); }
Example #2
Source File: LongStreamExTest.java From streamex with Apache License 2.0 | 5 votes |
@Test public void testDropWhile() { assertArrayEquals(new long[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, LongStreamEx.range(100).dropWhile( i -> i % 10 < 5).limit(10).toArray()); assertEquals(100, LongStreamEx.range(100).dropWhile(i -> i % 10 < 0).count()); assertEquals(0, LongStreamEx.range(100).dropWhile(i -> i % 10 < 10).count()); assertEquals(OptionalLong.of(0), LongStreamEx.range(100).dropWhile(i -> i % 10 < 0).findFirst()); assertEquals(OptionalLong.empty(), LongStreamEx.range(100).dropWhile(i -> i % 10 < 10).findFirst()); java.util.Spliterator.OfLong spltr = LongStreamEx.range(100).dropWhile(i -> i % 10 < 1).spliterator(); assertTrue(spltr.tryAdvance((long x) -> assertEquals(1, x))); Builder builder = LongStream.builder(); spltr.forEachRemaining(builder); assertArrayEquals(LongStreamEx.range(2, 100).toArray(), builder.build().toArray()); }