Class SetRootRule


  • public class SetRootRule
    extends AbstractMethodRule

    Rule implementation that calls a method on the root object on the stack, passing the top object (child) as an argument. It is important to remember that this rule acts on end.

    This rule now supports more flexible method matching by default. It is possible that this may break (some) code written against release 1.1.1 or earlier. See AbstractMethodRule.isExactMatch() for more details.

    • Constructor Detail

      • SetRootRule

        public SetRootRule​(java.lang.String methodName)
        Construct a "set root" rule with the specified method name. The method's argument type is assumed to be the class of the child object.
        Parameters:
        methodName - Method name of the parent method to call
      • SetRootRule

        public SetRootRule​(java.lang.String methodName,
                           java.lang.String paramType)
        Construct a "set root" rule with the specified method name.
        Parameters:
        methodName - Method name of the parent method to call
        paramType - Java class name of the parent method's argument (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such as java.lang.Boolean for a boolean parameter)
      • SetRootRule

        public SetRootRule​(java.lang.String methodName,
                           java.lang.Class<?> paramType)
        Construct a "set root" rule with the specified method name.
        Parameters:
        methodName - Method name of the parent method to call
        paramType - Java class of the parent method's argument (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such as java.lang.Boolean for a boolean parameter)
    • Method Detail

      • getChild

        protected java.lang.Object getChild()
        Returns the argument object of method has to be invoked.
        Specified by:
        getChild in class AbstractMethodRule
        Returns:
        the argument object of method has to be invoked.
      • getParent

        protected java.lang.Object getParent()
        Returns the target object of method has to be invoked.
        Specified by:
        getParent in class AbstractMethodRule
        Returns:
        the target object of method has to be invoked.