protected void addUnit ( String pattern , Unit base , String symbol , double factor , boolean metric ) { Unit unit = base . multiply ( factor ) ; unitPatterns . put ( Pattern . compile ( "\\b" + NUMBER_REGEX + "\\s{0," + WHITESPACE_LIMIT + "}" + pattern + "\\b" ) , unit ) ; unitSymbols . putIfAbsent ( unit , new ArrayList <> ( ) ) ; unitSymbols . get ( unit ) . add ( symbol ) ; if ( metric && ! metricUnits . contains ( unit ) ) { metricUnits . add ( unit ) ; } }
Associate a notation with a given unit .