protected int safeIntFromProperty ( StringProperty strProp , String field , List < FieldError > errorsBuilder , int min , int max ) { String s = strProp . get ( ) ; if ( StringHelper . isStringEmptyOrNull ( s ) ) { return 0 ; } int val = 0 ; try { val = Integer . valueOf ( s ) ; if ( val < min || val > max ) { errorsBuilder . add ( new FieldError ( "Value must be between " + min + " and " + max , field ) ) ; } } catch ( NumberFormatException e ) { errorsBuilder . add ( new FieldError ( "Value must be a number" , field ) ) ; } return val ; }
Gets the integer value from a text field property and validates it again the conditions provided . It must be a number and within the ranges provided .