Class Params


  • public class Params
    extends Object
    Utility class for marshalling invokable operation parameters and return values
    • Constructor Detail

      • Params

        public Params()
    • Method Detail

      • formatParams

        public static Map<String,​Object> formatParams​(Operation operation,
                                                            Map<String,​Object> params)
        Creates the "params" part of the invoke payload using the spec in the operation metadata and the passed positional arguments
        Parameters:
        operation - The operation to format the parameters for
        params - A map of parameter names to assets
        Returns:
        The "params" portion of the invoke payload as a Map
        Throws:
        IllegalArgumentException - if missing required parameter
      • formatResponse

        public static Map<String,​Object> formatResponse​(Operation operation,
                                                              Map<String,​Object> res,
                                                              RemoteAgent remoteAgent)
        This method is used to format result of the response form Invoke calls. It will map the result data of the response to result defined in the metadata Eg: if the result of the response is type Json ,then it type caste the response to Json if the result of the response is type asset, then it ype caste the response map to asset.
        Parameters:
        operation - instance reference
        res - response received from the Invoke call
        remoteAgent - agent on which this operation has done.
        Returns:
        formatted map of the response received
      • formatParams

        public static Map<String,​Object> formatParams​(Operation operation,
                                                            Object... params)
        Creates the "params" part of the invoke payload using the spec in the operation metadata and the passed positional arguments
        Parameters:
        operation - The operation to format the parameters for
        params - An array of assets to be provided as positional parameters
        Returns:
        The "params" portion of the invoke payload as a JSONObject
        Throws:
        IllegalArgumentException - if missing required parameter
      • namedParams

        public static Map<String,​Object> namedParams​(Operation operation,
                                                           Object... params)
        Converts an array of positional parameters to a map of named parameters, according to the parameter spec of the given operation.
        Parameters:
        operation - need to get the meta data
        params - all asset on which the validation need to be done
        Returns:
        A new map containing the named parameters
        Throws:
        IllegalArgumentException - if a require dparameter is not provided