public static Constraint build ( String cname , Map < String , Object > payload ) { if ( cname != null && payload != null ) { if ( "min" . equals ( cname ) && payload . containsKey ( "value" ) ) { return min ( NumberUtils . toLong ( payload . get ( "value" ) + "" , 0 ) ) ; } else if ( "max" . equals ( cname ) && payload . containsKey ( "value" ) ) { return max ( NumberUtils . toLong ( payload . get ( "value" ) + "" , Config . DEFAULT_LIMIT ) ) ; } else if ( "size" . equals ( cname ) && payload . containsKey ( "min" ) && payload . containsKey ( "max" ) ) { return size ( NumberUtils . toLong ( payload . get ( "min" ) + "" , 0 ) , NumberUtils . toLong ( payload . get ( "max" ) + "" , Config . DEFAULT_LIMIT ) ) ; } else if ( "digits" . equals ( cname ) && payload . containsKey ( "integer" ) && payload . containsKey ( "fraction" ) ) { return digits ( NumberUtils . toLong ( payload . get ( "integer" ) + "" , 0 ) , NumberUtils . toLong ( payload . get ( "fraction" ) + "" , 0 ) ) ; } else if ( "pattern" . equals ( cname ) && payload . containsKey ( "value" ) ) { return pattern ( payload . get ( "value" ) ) ; } else { return SIMPLE_CONSTRAINTS . get ( cname ) ; } } return null ; }
Builds a new constraint from a given name and payload .