private Object fetchValue(Object o) throws IllegalAccessException, InvocationTargetException { if ( name instanceof NameRefNode ) { o = EvalHelper.getValue( o, name.getText() ); } else if ( name instanceof QualifiedNameNode ) { for ( NameRefNode nr : ((QualifiedNameNode) name).getParts() ) { o = EvalHelper.getValue( o, nr.getText() ); } } return o; }
@Override public Object evaluate(EvaluationContext ctx) { Object current = parts.get( 0 ).evaluate( ctx ); try { if ( current != null ) { for ( int i = 1; i < parts.size(); i++ ) { String n = parts.get( i ).getText(); if ( current instanceof Collection ) { // e.g.: FEEL: MyList.property1 // can't use Stream API as from EvalHelper.getValue I need to listen for checked exception Collection<Object> result = new ArrayList<>(); for ( Object e : (Collection<?>) current ) { result.add( EvalHelper.getValue( e, EvalHelper.normalizeVariableName( n ) ) ); } current = result; } else { current = EvalHelper.getValue( current, EvalHelper.normalizeVariableName( n ) ); } } return current; } } catch ( Exception e ) { ctx.notifyEvt( astEvent(Severity.ERROR, Msg.createMessage(Msg.ERROR_ACCESSING_QUALIFIED_NAME, getText()), e) ); return null; } return null; }