I'm looking for a way to limit the size of a class properties. Users can create new instances and I want to limit that some String property must have from n to m characters, or another Integer property must be a whole number from some range.
I haven't found any way to do this in the class definition, do I need to define my methods like:
public String checkInput (String input, int length) {
if (input.length() > length) {
return input.substring(0, length);
} else return input;
}