@Override public void setValue(Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public void setValue(EvaluationContext context, Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public void setValue(Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public void setValue(EvaluationContext context, Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public Object operate(Operation operation, @Nullable Object leftOperand, @Nullable Object rightOperand) throws EvaluationException { throw new EvaluationException("No operation overloaded by default"); }
@Override public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public void setValue(Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public void setValue(EvaluationContext context, Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression"); }
@Override public void setValue(Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public void setValue(EvaluationContext context, Object rootObject, @Nullable Object value) throws EvaluationException { throw new EvaluationException(this.literalValue, "Cannot call setValue() on a LiteralExpression"); }
@Override public Object operate(Operation operation, @Nullable Object leftOperand, @Nullable Object rightOperand) throws EvaluationException { throw new EvaluationException("No operation overloaded by default"); }
/** * Determines if there is a type converter available in the specified context and * attempts to use it to convert the supplied value to the specified type. Throws an * exception if conversion is not possible. * @param context the evaluation context that may define a type converter * @param typedValue the value to convert and a type descriptor describing it * @param targetType the type to attempt conversion to * @return the converted value * @throws EvaluationException if there is a problem during conversion or conversion * of the value to the specified type is not supported */ @SuppressWarnings("unchecked") @Nullable public static <T> T convertTypedValue( @Nullable EvaluationContext context, TypedValue typedValue, @Nullable Class<T> targetType) { Object value = typedValue.getValue(); if (targetType == null) { return (T) value; } if (context != null) { return (T) context.getTypeConverter().convertValue( value, typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(targetType)); } if (ClassUtils.isAssignableValue(targetType, value)) { return (T) value; } throw new EvaluationException("Cannot convert value '" + value + "' to type '" + targetType.getName() + "'"); }
/** * Determines if there is a type converter available in the specified context and * attempts to use it to convert the supplied value to the specified type. Throws an * exception if conversion is not possible. * @param context the evaluation context that may define a type converter * @param typedValue the value to convert and a type descriptor describing it * @param targetType the type to attempt conversion to * @return the converted value * @throws EvaluationException if there is a problem during conversion or conversion * of the value to the specified type is not supported */ @SuppressWarnings("unchecked") @Nullable public static <T> T convertTypedValue( @Nullable EvaluationContext context, TypedValue typedValue, @Nullable Class<T> targetType) { Object value = typedValue.getValue(); if (targetType == null) { return (T) value; } if (context != null) { return (T) context.getTypeConverter().convertValue( value, typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(targetType)); } if (ClassUtils.isAssignableValue(targetType, value)) { return (T) value; } throw new EvaluationException("Cannot convert value '" + value + "' to type '" + targetType.getName() + "'"); }
@Override public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException { throw new EvaluationException(this.value.toString(), "Cannot call setValue() on a ValueExpression"); }
public SupplierExpression(Supplier<T> supplier) { Assert.notNull(supplier, "'function' must not be null."); this.supplier = supplier; this.readOnlyException = new EvaluationException(getExpressionString(), "SupplierExpression is a 'read only' Expression implementation"); }
public FunctionExpression(Function<S, ?> function) { Assert.notNull(function, "'function' must not be null."); this.function = function; this.readOnlyException = new EvaluationException(getExpressionString(), "FunctionExpression is a 'read only' Expression implementation"); }
private void validateMethod(Object targetObject, String name, int argumentCount) { if (this.methodFilter == null) { return; } Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass()); Method[] methods = type.getMethods(); List<Method> candidates = new ArrayList<Method>(); for (Method method : methods) { if (method.getName().equals(name) && method.getParameterTypes().length == argumentCount) { candidates.add(method); } } List<Method> supportedMethods = this.methodFilter.filter(candidates); if (supportedMethods.size() == 0) { String methodDescription = (candidates.size() > 0) ? candidates.get(0).toString() : name; throw new EvaluationException("The method '" + methodDescription + "' is not supported by this command processor. " + "If using the Control Bus, consider adding @ManagedOperation or @ManagedAttribute."); } } }