Creates an {@link InputMapping} based on a argument.
@return {@link ExpressionLanguageMapping} for string arguments of style "${expression}",
or a {@link ConstantMapping} otherwise.
427432
private static InputMapping<Object> createInputMapping( Object value ){
        if( value instanceof String ){
            String text = (String)value;
            if( ElUtil.hasBrackets( text ) ){
                return new ExpressionLanguageMapping<Object>( text );
            }
        }
        return ConstantMapping.of( value );
    }
1035804
public Expression construct(final Iterable<? extends Expression> args) {
    Expression.checkTypes(argTypes(), args);
    return new Expression(instanceClass().type(), Feature.NON_NULLABLE) {
      @Override
      protected void doGen(CodeBuilder mv) {
        mv.newInstance(instanceClass().type());
        // push a second reference onto the stack so there is still a reference to the new object
        // after invoking the constructor (constructors are void methods)
        mv.dup();
        for (Expression arg : args) {
          arg.gen(mv);
        }
        mv.invokeConstructor(instanceClass().type(), method());
      }
    };
  }
869023
public static JSTypeExpression makeOptionalArg(JSTypeExpression expr) {
    if (expr.isOptionalArg() || expr.isVarArgs()) {
      return expr;
    } else {
      return new JSTypeExpression(
          new Node(Token.EQUALS, expr.root), expr.sourceName);
    }
  }
1081773
public static ImmutableMap<Symbol, Symbol> mapFrom(Map<String, String> stringMap) {
    final ImmutableMap.Builder<Symbol, Symbol> ret = ImmutableMap.builder();

    for (Map.Entry<String, String> stringEntry : stringMap.entrySet()) {
      ret.put(Symbol.from(stringEntry.getKey()),
          Symbol.from(stringEntry.getValue()));
    }

    return ret.build();
  }
91829
public static Map<String, List<Object>> getListMap(Message message, List<ExpressionMapping> expressionMappings, boolean expand, String undefinedVariable) {
        return getListMap(message, expressionMappings, expand, undefinedVariable, null);
    }
790826
protected Map<Character, List<Pair<FeaturePattern, FeatureReplacement>>> initMapping() {
		final Map<Character, List<Pair<FeaturePattern, FeatureReplacement>>> map = new TreeMap<>();
		if (!this.ruleReader.initializeConversions(map, this.context) && this.initializer != null) {
			this.initializer.initializeConversions((simpleName, source, target) -> {
				final char c = getKey(simpleName);
				if (c == FeaturePattern.ALL_PATTERN_CHAR) {
					for (int i = 'a'; i <= 'z'; ++i) {
						createMappingEntry(map, (char) i, source, target);
					}
				} else {
					createMappingEntry(map, c, source, target);
				}
			});
		}
		return map;
	}
1005782
protected void generateExpressionAppender() {
		final TypeReference builderInterface = getExpressionBuilderInterface();
		final TypeReference appender = getCodeElementExtractor().getElementAppenderImpl("Expression"); //$NON-NLS-1$
		final StringConcatenationClient content = new StringConcatenationClient() {
			@Override
			protected void appendTo(TargetStringConcatenation it) {
				it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
						+ " XExpression."); //$NON-NLS-1$
				it.newLine();
				it.append(" */"); //$NON-NLS-1$
				it.newLine();
				it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
				it.newLine();
				it.append("public class "); //$NON-NLS-1$
				it.append(appender.getSimpleName());
				it.append(" extends "); //$NON-NLS-1$
				it.append(getCodeElementExtractor().getAbstractAppenderImpl());
				it.append(" implements "); //$NON-NLS-1$
				it.append(builderInterface);
				it.append(" {"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
				it.append(generateAppenderMembers(appender.getSimpleName(),
						builderInterface, "getXExpression()")); //$NON-NLS-1$
				it.append(generateMembers(false, true));
				it.append("}"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
			}
		};
		final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
		javaFile.writeTo(getSrcGen());
	}
208037
@Nonnull
    private static RuleEvaluator makeRuleEvaluator(final ExpressionFactory expressionFactory, final FunctionMapper functionMapper) {
        // Make the expression evaluation context.
        final Map<String, Object> testConstants = Collections.emptyMap();

        return new RuleEvaluator(expressionFactory, functionMapper, testConstants);
    }
700844
public static <V> Mapping<Map<String, V>> map(Mapping<V> vBase, Constraint... constraints) {
        return map(text(), vBase, constraints);
    }
305701
public Expression getFromExpression() {
        if (_fromExpression == null && _from != null) {
            _fromExpression = ExpressionFactory.INSTANCE.create(_from, null, _propertyResolver);
        }
        return _fromExpression;
    }
769804
public <V> ResultTransformer<Map<K, V>> as(FactoryExpression<V> expression) {
        final FactoryExpression<?> transformation = FactoryExpressionUtils.wrap(expression);
        List<Expression<?>> args = transformation.getArgs();
        return new GroupByMap<K, V>(key, args.toArray(new Expression<?>[args.size()])) {

            @Override
            protected Map<K, V> transform(Map<K, Group> groups) {
                Map<K, V> results = new LinkedHashMap<K, V>((int) Math.ceil(groups.size() / 0.75), 0.75f);
                for (Map.Entry<K, Group> entry : groups.entrySet()) {
                    results.put(entry.getKey(), transform(entry.getValue()));
                }
                return results;
            }

            @SuppressWarnings("unchecked")
            protected V transform(Group group) {
                // XXX Isn't group.toArray() suitable here?
                List<Object> args = new ArrayList<Object>(groupExpressions.size() - 1);
                for (int i = 1; i < groupExpressions.size(); i++) {
                    args.add(group.getGroup(groupExpressions.get(i)));
                }
                return (V) transformation.newInstance(args.toArray());
            }

        };
    }
1084914
public static Expression compile(String exp) {
        if (Miscellaneous.isEmpty(exp) || exp.equals(".")) {
            exp = "$";
        }
        Queue<String> queue = new LinkedList<String>();
        List<String> tokens = parseTokens(exp);
        boolean isInBracket = false;
        int numInBracket = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < tokens.size(); i++) {
            String token = tokens.get(i);
            if (token.equals("[")) {
                if (isInBracket) {
                    throw new IllegalArgumentException("Error parsing expression '" + exp + "': Nested [ found");
                }
                isInBracket = true;
                numInBracket = 0;
                sb.append(token);
            } else if (token.equals("]")) {
                if (!isInBracket) {
                    throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced ] found");
                }
                isInBracket = false;
                sb.append(token);
                queue.add(sb.toString());
                sb = new StringBuilder();
            } else {
                if (isInBracket) {
                    if (numInBracket > 0) {
                        throw new IllegalArgumentException("Error parsing expression '" + exp + "': Multiple tokens found inside a bracket");
                    }
                    sb.append(token);
                    numInBracket++;
                } else {
                    queue.add(token);
                }
            }
            if (i == tokens.size() - 1) {
                if (isInBracket) {
                    throw new IllegalArgumentException("Error parsing expression '" + exp + "': Unbalanced [ found");
                }
            }
        }
        return new Expression(queue, exp);
    }
172454
public static boolean isConstantOrConstantLiteral(Expression expression) {
        return expression instanceof ConstantExpression ||
            isPredefinedConstant(expression) ||
            isMapLiteralWithOnlyConstantValues(expression) ||
            isListLiteralWithOnlyConstantValues(expression);
    }
1234357
public TemplateTypeMap createTemplateTypeMap(
      ImmutableList<TemplateType> templateKeys,
      ImmutableList<JSType> templateValues) {
    if (templateKeys == null) {
      templateKeys = ImmutableList.of();
    }
    if (templateValues == null) {
      templateValues = ImmutableList.of();
    }
    return (templateKeys.isEmpty() && templateValues.isEmpty())
        ? emptyTemplateTypeMap
            : new TemplateTypeMap(this, templateKeys, templateValues);
  }
1180915
public static SearchExpressionResolver findResolver(final String expression) {
        SearchExpressionResolver resolver = null;

        if (expression.startsWith(SearchExpressionConstants.KEYWORD_PREFIX)) {
            // check if it's an expression with parameter
            int parenthesisPosition = expression.indexOf('(');
            if (parenthesisPosition > 0) {
                String expressionWithoutParam = expression.substring(0, parenthesisPosition);
                resolver = RESOLVER_MAPPING.get(expressionWithoutParam);
            }
            else {
                resolver = RESOLVER_MAPPING.get(expression);
            }
        }
        else {
            // if it's not a keyword, just delegate it to JSF
            resolver = FIND_COMPONENT_EXPRESSION_RESOLVER;
        }

        if (resolver == null) {
            throw new FacesException("No SearchExpressionResolver available for expression \"" + expression + "\"");
        }

        return resolver;
    }
150747
private MethodCallExpression createMethodCallExpression(Expression baseExpr, Expression arguments) {
        return new MethodCallExpression(
                VariableExpression.THIS_EXPRESSION,

                (baseExpr instanceof VariableExpression)
                        ? this.createConstantExpression(baseExpr)
                        : baseExpr,

                arguments
        );
    }
768783
public static Map<String, Object> onInExpression(Expression expression, EntityMetadata m,
            KunderaMetadata kunderaMetadata, KunderaQuery kunderaQuery)
    {
        InExpression inExp = (InExpression) expression;
        Expression sfpExp = inExp.getExpression();
        Map<String, Object> map = KunderaQueryUtils.setFieldClazzAndColumnFamily(sfpExp, m, kunderaMetadata);
        kunderaQuery.addFilterClause(
              (String) map.get(Constants.COL_NAME), inExp.getIdentifier(), inExp.getInItems(),
              (String) map.get(Constants.FIELD_NAME), (Boolean) map.get(Constants.IGNORE_CASE));
        return map;
    }