use of java.util.stream.LongStream.Builder in project streamex by amaembo.
the class LongStreamExTest method testDropWhile.
@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());
}
use of java.util.stream.LongStream.Builder in project taskana by Taskana.
the class WorkingDaysToDaysConverter method isGermanHoliday.
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);
}
Aggregations