It sounds like you want...
(Wait for it...)
... a class with two integers and a string.
public final class RangeValidation {
private final int minimum;
private final int maximum;
private final String message;
public RangeValidation(int minimum, int maximum, String message) {
if (minimum > maximum) {
throw new IllegalArgumentException("Invalid min/max combination");
}
if (message == null) {
throw new NullPointerException();
}
this.minimum = minimum;
this.maximum = maximum;
this.message = message;
}
// You can tweak this API, of course...
// it could throw an exception instead, or return an empty string for
// success, etc.
public String validate(int value) {
return value < minimum || value > maximum ? mesasge : null;
}
}
Of course you may want to make this implement an interface to fit in with a more general validation framework etc... but the important point is that you've already neatly describe what you want your type to contain - so you just need to write it.
Also note that this counts the maximum value as inclusive - you may wish to make it exclusive, in order to be able to represent empty ranges. (That does make it harder to represent a range for which Integer.MAX_VALUE is valid though...)