protected < T extends CSSProperty > boolean genericTerm ( Class < ? extends Term < ? > > termType , Term < ? > term , String propertyName , T typeIdentification , ValueRange range , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { // check type if ( termType . isInstance ( term ) ) { // sanity check if ( range != ValueRange . ALLOW_ALL ) { // check for integer if ( term . getValue ( ) instanceof Integer ) { final Integer zero = 0 ; int result = zero . compareTo ( ( Integer ) term . getValue ( ) ) ; if ( result > 0 ) { // return false is also possibility // but we will change to zero if ( range == ValueRange . TRUNCATE_NEGATIVE ) ( ( TermInteger ) term ) . setZero ( ) ; else return false ; } else if ( result == 0 ) { if ( range == ValueRange . DISALLOW_ZERO ) { return false ; } } } // check for float else if ( term . getValue ( ) instanceof java . lang . Float ) { final java . lang . Float zero = 0f ; int result = zero . compareTo ( ( java . lang . Float ) term . getValue ( ) ) ; if ( result > 0 ) { // return false is also possibility // but we will change to zero if ( range == ValueRange . TRUNCATE_NEGATIVE ) ( ( TermFloatValue ) term ) . setZero ( ) ; else return false ; } else if ( result == 0 ) { if ( range == ValueRange . DISALLOW_ZERO ) { return false ; } } } } // passed both type check and range check, // store properties . put ( propertyName , typeIdentification ) ; values . put ( propertyName , term ) ; return true ; } return false ; }
Check whether given declaration contains one term of given type . It is able to check even whether is above zero for numeric values