package jadex.rules.rulesystem.rules.functions; import jadex.rules.rulesystem.rete.extractors.AttributeSet; import jadex.rules.rulesystem.rules.ILazyValue; import jadex.rules.state.IOAVState; /** * Return the given value. */ // Hack!!! Required to add new values into conditions. public class Identity implements IFunction { /** * Invoke a function and return a value (optional). * @param paramvalues The parameter values. * @return The function value. */ public Object invoke(Object[] paramvalues, IOAVState state) { if(paramvalues==null || paramvalues.length!=1) throw new IllegalArgumentException("Function needs one parameter: "+paramvalues); Object val1 = paramvalues[0] instanceof ILazyValue? ((ILazyValue)paramvalues[0]).getValue(): paramvalues[0]; return val1; } /** * Get the return type of this function. */ public Class getReturnType() { return Object.class; } /** * Get the set of relevant attribute types. * @return The relevant attribute types. */ public AttributeSet getRelevantAttributes() { return AttributeSet.EMPTY_ATTRIBUTESET; } /** * Get the string representation. * @return The string representation. */ public String toString() { return "identity"; } /** * Test for equality. */ public boolean equals(Object obj) { return obj instanceof Identity; } }