@Override public Object apply(List<Object> args, Context context) throws ParseException { Map<String, StellarExecutor.VariableResult> variables = (Map<String, StellarExecutor.VariableResult>) context.getCapability(StellarExecutor.SHELL_VARIABLES).get(); if (args.size() == 0) { return null; } String variable = (String) args.get(0); if (variable == null) { return null; } StellarExecutor.VariableResult result = variables.get(variable); if (result != null && result.getExpression() != null) { return result.getExpression(); } return null; }
@Override public Object apply(List<Object> args, Context context) throws ParseException { Map<String, StellarExecutor.VariableResult> variables = (Map<String, StellarExecutor.VariableResult>) context.getCapability(StellarExecutor.SHELL_VARIABLES).get(); LinkedHashMap<String, String> ret = new LinkedHashMap<>(); for (Object arg : args) { if (arg == null) { continue; } String variable = (String) arg; StellarExecutor.VariableResult result = variables.get(variable); if (result != null && result.getExpression() != null) { ret.put(variable, result.getExpression()); } } return ret; }