IPAddress implements Range<IPAddress> { @Override public boolean isInRange(IPAddress candidate) { return Optional.ofNullable(candidate) .map(IPAddress::value) .map(value()::equals) .orElse(Boolean.FALSE); }  @Value.Parameter abstract String value(); @Override boolean isInRange(IPAddress candidate); @Value.Lazy boolean greaterOrEqualsTo(IPAddress candidate); @Value.Lazy boolean lessOrEqualsTo(IPAddress candidate);  }
@Test public void in_range() throws Exception { final Range<IPAddress> range = ImmutableIPAddress.of("127.0.0.1"); Assertions.assertThat(range.isInRange(ImmutableIPAddress.of("127.0.0.1"))).isTrue(); Assertions.assertThat(range.isInRange(ImmutableIPAddress.of("127.0.0.2"))).isFalse(); Assertions.assertThat(range.isInRange(ImmutableIPAddress.of("127.0.0.3"))).isFalse(); }