All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.numenta.nupic.util.MethodSignature Maven / Gradle / Ivy

package org.numenta.nupic.util;

/**
 * 

* {@link Tuple} type that allows the setting of method parameters * while setting those parameters on this object - in the same statement. *

* This class is handy to avoid instantiating new {@link Tuple}s during highly * iterative processes. *

* * @author David Ray * @see MutableTuple * @see NamedTuple * @see Tuple * @see #setParam(Object, int) */ public class MethodSignature extends MutableNamedTuple { private static final long serialVersionUID = 1L; public MethodSignature() { } /** *

* Special setter which allows the setting of fields within * this object while specifying the parameters of a method's * call site. It does this by returning the value that the * {@link #setParam(Object, int)} method is called with. *

*

     *      public void someMethod(A a, B b) {}
     *      
     *      MethodSignature ms = new MethodSignature(2);
     *      
     *      A a = new A();
     *      B b = new B();
     *      someMethod(ms.addParam(a, "A"), ms.addParam(b, "B"));
     *      
     *      -- OR --
     *      
     *      public void someMethod(MethodSignature ms) {}
     *      someMethod(new MethodSignature(2).setParams(new String[] { "name1", "name2" }, value1, value2));
     *      
     *      -- OR --
     *      
     *      public void someMethod(Tuple t) {}
     *      someMethod(new MethodSignature(2).setParams(new String[] { "name1", "name2" }, value1, value2)));
     * 
* * @param t the value * @param name the name of the parameter * * @return */ public T addParam(T t, String name) { super.put(name, t); return t; } /** * Allows the setting of contents within this object in the call * site of a method which takes an instance of this {@link MethodSignature} * object. * * @param paramNames the parameter names * @param objects the parameter values * @return this {@code MethodSignature} * @see #setParam(Object, int) */ public MethodSignature setParams(String[] paramNames, Object... objects) { remake(paramNames, objects); return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy