LongDomain extends NumberDomain<Long> { public void setRange( Range range) { Optional<Range> ifRange = Optional.ofNullable( range); setExcluded( ifRange.map( Range::getExcluded).orElse( emptySet()) .stream() .map( Long::valueOf) .collect( toSet())); setRange( Optional.ofNullable( ifRange.map( Range::getMin).orElse( null)) .map( Long::valueOf) .map( i -> ifRange.map( Range::isMinExclusive).orElse( false)? i + 1 : i) .orElse( -getMaxRange()), Optional.ofNullable( ifRange.map( Range::getMax).orElse( null)) .map( Long::valueOf) .map( i -> ifRange.map( Range::isMaxExclusive).orElse( false)? i - 1 : i) .orElse( getMaxRange())); } LongDomain();  LongDomain( long maxRange);  LongDomain( long min, long max);  LongDomain( Range range); void setRange( Range range); void setRange( Long min, Long max); void setMultipleOf( String multipleOf); void setNotMultipleOfs( String[] notMultipleOfs); Stream<DataValue<Long>> values( ResolverContext context);  }
@Test public void whenRangeTooBig() { LongDomain domain = new LongDomain(); expectFailure( IllegalArgumentException.class) .when( () -> domain.setRange( -1L, Long.MAX_VALUE)); }
@Test public void whenExcluded() { LongDomain domain = new LongDomain(); domain.setRange( Range.of( VarBindingBuilder.with( "Long") .value( "Other") .has( "excluded", 2L, 3L, 5L, 8L, 13L, 21L).build())); verifyContainsValues( domain, 1000); assertThat( "Contains", domain.contains( -2345L), is( true)); assertThat( "Contains", domain.contains( 21L), is( false)); assertThat( "Contains", domain.contains( 4L), is( true)); }