/** * Sets the {@link ValueExpression} used to calculate the value for the specified property name. * * @param name Name of the property for which to set a {@link ValueExpression} * @param binding The {@link ValueExpression} to set, or <code>null</code> to remove any currently * set {@link ValueExpression} * @throws NullPointerException if <code>name</code> is <code>null</code> */ public void setValueExpression(String name, ValueExpression binding) { if (name == null) { throw new NullPointerException(); } if (binding != null) { if (binding.isLiteralText()) { setLiteralValue(name, binding); } else { if (bindings == null) { // We use a very small initial capacity on this HashMap. // The goal is not to reduce collisions, but to keep the // memory footprint small. It is very unlikely that an // an AjaxBehavior would have more than 1 or 2 bound // properties - and even if more are present, it's okay // if we have some collisions - will still be fast. bindings = new HashMap<String, ValueExpression>(6, 1.0f); } bindings.put(name, binding); } } else { if (bindings != null) { bindings.remove(name); if (bindings.isEmpty()) { bindings = null; } } } clearInitialState(); }