public static Object getRestrictedValue ( Selector selector , SelectorType type ) throws ExecutionException { Object field = null ; if ( type != null && selector . getType ( ) != type ) { throw new ExecutionException ( "The selector type expected is: " + type + " but received: " + selector . getType ( ) ) ; } switch ( selector . getType ( ) ) { case COLUMN : field = ( ( ColumnSelector ) selector ) . getName ( ) . getName ( ) ; break ; case BOOLEAN : field = ( ( BooleanSelector ) selector ) . getValue ( ) ; break ; case STRING : field = ( ( StringSelector ) selector ) . getValue ( ) ; break ; case INTEGER : field = ( ( IntegerSelector ) selector ) . getValue ( ) ; break ; case FLOATING_POINT : field = ( ( FloatingPointSelector ) selector ) . getValue ( ) ; break ; case GROUP : field = getRestrictedValue ( ( ( GroupSelector ) selector ) . getFirstValue ( ) , null ) ; break ; case LIST : if ( ( ( ListSelector ) selector ) . getSelectorsList ( ) . isEmpty ( ) ) { throw new ExecutionException ( "Selector " + selector . getType ( ) + " not supported get value operation." ) ; } field = getRestrictedValue ( ( ( ListSelector ) selector ) . getSelectorsList ( ) . get ( 0 ) , null ) ; break ; default : throw new ExecutionException ( "Selector " + selector . getType ( ) + " not supported get value operation." ) ; } return field ; }
Return the selector value only if the type matches with the specified value .