Class HierarchicalParametersCallback

java.lang.Object
scriptella.spi.support.HierarchicalParametersCallback
All Implemented Interfaces:
ParametersCallback

public class HierarchicalParametersCallback extends Object implements ParametersCallback
Hierarchical implementation of ParametersCallback interface.

This class decorates behaviour of a primary callback by obtaining absent parameter values from the parent callback.

Note: This class is mutable and not thread-safe.

Version:
1.0
Author:
Fyodor Kupolov
  • Constructor Details

    • HierarchicalParametersCallback

      public HierarchicalParametersCallback(ParametersCallback callback, ParametersCallback parentCallback)
      Creates a hierarchical parameters callback instance.
      Parameters:
      callback - primary callback.
      parentCallback - secondary (parent) callback. If null - only primary callback is used.
  • Method Details

    • getCallback

      public ParametersCallback getCallback()
      Returns primary callback.
      Returns:
      primary callback.
    • setCallback

      public void setCallback(ParametersCallback callback)
      Sets primary callback.
      Parameters:
      callback - primary callback. Cannot be null.
    • getParentCallback

      public ParametersCallback getParentCallback()
      Returns secondary callback.
      Returns:
      secondary callback.
    • setParentCallback

      public void setParentCallback(ParametersCallback parentCallback)
      Sets secondary callback.
      Parameters:
      parentCallback - secondary callback. May be null, in this case only primary callback is used.
    • getParameter

      public Object getParameter(String name)
      This method obtains the value of a specified parameter from the primary callback . If the returned value is null, the parameter's value is obtained from secondary callback.
      Specified by:
      getParameter in interface ParametersCallback
      Parameters:
      name - parameter name.
      Returns:
      value of the specified parameter.