boon/src/main/java/org/boon/criteria/Selector.java
public static Selector selectAs( final String propName, final String alias,
                                     final Function transform) {
        return new Selector( propName, alias ) {

            @Override
            public void handleRow( int index, Map<String, Object> row,
                                   Object item, Map<String, FieldAccess> fields ) {

                if (!path && fields!=null) {
                    row.put( this.name, transform.apply(fields.get( this.name ).getValue( item )) );
                } else {
                    row.put( alias, transform.apply(BeanUtils.atIndex( item, propName ))  );
                }
            }

            @Override
            public void handleStart( Collection<?> results ) {
            }

            @Override
            public void handleComplete( List<Map<String, Object>> rows ) {
            }
        };
    }
public static Selector selectAs( final String propName, final String alias,
                                     final Function transform) {
        return new Selector( propName, alias ) {

            @Override
            public void handleRow( int index, Map<String, Object> row,
                                   Object item, Map<String, FieldAccess> fields ) {

                if (!path && fields!=null) {
                    row.put( this.name, transform.apply(fields.get( this.name ).getValue( item )) );
                } else {
                    row.put( alias, transform.apply(BeanUtils.atIndex( item, propName ))  );
                }
            }

            @Override
            public void handleStart( Collection<?> results ) {
            }

            @Override
            public void handleComplete( List<Map<String, Object>> rows ) {
            }
        };
    }
public static Selector selectAs ( final String propName , final String alias , final Function transform ) { return new Selector ( propName , alias ) { @ Override public void handleRow ( int index , Map < String , Object > row , Object item , Map < String , FieldAccess > fields ) { if ( ! path && fields != null ) { row . put ( this . name , transform . apply ( fields . get ( this . name ) . getValue ( item ) ) ) ; } else { row . put ( alias , transform . apply ( BeanUtils . atIndex ( item , propName ) ) ) ; } } @ Override public void handleStart ( Collection < ? > results ) { } @ Override public void handleComplete ( List < Map < String , Object > > rows ) { } } ; }
Selects but allows having a different alias for the output.
@param propName name of property or property path to select
@param alias name that the value will be selected as.
@param transform Function that allows you to convert from an object into another object
@return selector
Selects but allows having a different alias for the output .