public < T > Evaluator < T > create ( QueryMetadata metadata , List < ? extends Expression < ? > > sources , Expression < T > projection ) { final CollQuerySerializer serializer = new CollQuerySerializer ( templates ) ; serializer . append ( "return " ) ; if ( projection instanceof FactoryExpression < ? > ) { serializer . append ( "(" ) ; serializer . append ( ClassUtils . getName ( projection . getType ( ) ) ) ; serializer . append ( ")(" ) ; serializer . handle ( projection ) ; serializer . append ( ")" ) ; } else { serializer . handle ( projection ) ; } serializer . append ( ";" ) ; Map < Object , String > constantToLabel = serializer . getConstantToLabel ( ) ; Map < String , Object > constants = getConstants ( metadata , constantToLabel ) ; Class < ? > [ ] types = new Class < ? > [ sources . size ( ) ] ; String [ ] names = new String [ sources . size ( ) ] ; for ( int i = 0 ; i < sources . size ( ) ; i ++ ) { types [ i ] = sources . get ( i ) . getType ( ) ; names [ i ] = sources . get ( i ) . toString ( ) ; } // normalize types for ( int i = 0 ; i < types . length ; i ++ ) { if ( Primitives . isWrapperType ( types [ i ] ) ) { types [ i ] = Primitives . unwrap ( types [ i ] ) ; } } return factory . createEvaluator ( serializer . toString ( ) , projection . getType ( ) , names , types , constants ) ; }
Create an Evaluator for the given query sources and projection