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