class ExpressionFieldAction implements AtlasFieldAction {

    @AtlasActionProcessor
    public static Object process(io.atlasmap.v2.Expression action, List<Object> args) throws ExpressionException {
        if (action.getExpression() == null || action.getExpression().trim().isEmpty()) {
            return null;
        }

        Expression parsedExpression = Expression.parse(action.getExpression(), DefaultAtlasFunctionResolver.getInstance());
        Field answer = parsedExpression.evaluate((index) -> {
            try {
                return wrapWithField(args.get(Integer.parseInt(index)));
            } catch (Throwable e) {
                throw new ExpressionException("Invalid variable: " + index);
            }
        });
        return unwrapField(answer);
    }

}