@ Override public IScan getScanByNumClosest ( int scanNum ) { IScan result = null ; Map . Entry < Integer , IScan > lower = getNum2scan ( ) . lowerEntry ( scanNum ) ; Map . Entry < Integer , IScan > upper = getNum2scan ( ) . ceilingEntry ( scanNum ) ; if ( upper != null && lower != null ) { result = Integer . compare ( lower . getKey ( ) , upper . getKey ( ) ) > 0 ? lower . getValue ( ) : upper . getValue ( ) ; } else if ( upper != null ) { result = upper . getValue ( ) ; } else if ( lower != null ) { result = lower . getValue ( ) ; } return result ; }
Scan with the closest Number is returned .