protected static Unit inputFromExactUnit ( Unit exact , UnitConverter converter ) { switch ( exact ) { case TERABIT : case GIGABIT : case MEGABIT : case KILOBIT : case BIT : return Unit . BIT ; case TERABYTE : case GIGABYTE : case MEGABYTE : case KILOBYTE : case BYTE : return Unit . BYTE ; default : break ; } UnitCategory category = exact . category ( ) ; switch ( category ) { case CONSUMPTION : return converter . consumptionUnit ( ) ; case ELECTRIC : return Unit . AMPERE ; case FREQUENCY : return Unit . HERTZ ; case LIGHT : return Unit . LUX ; case PRESSURE : return Unit . MILLIBAR ; case SPEED : return converter . speedUnit ( ) ; case TEMPERATURE : return converter . temperatureUnit ( ) ; default : UnitFactorSet factorSet = getDefaultFactorSet ( category , converter ) ; if ( factorSet != null ) { return factorSet . base ( ) ; } break ; } return null ; }
Based on the unit we re converting to guess the input unit . For example if we re converting to MEGABIT and no input unit was specified assume BIT .