Package sg.dex.starfish.util
Class Params
- java.lang.Object
-
- sg.dex.starfish.util.Params
-
public class Params extends Object
Utility class for marshalling invokable operation parameters and return values
-
-
Constructor Summary
Constructors Constructor Description Params()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 argumentsstatic 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 argumentsstatic 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.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.
-
-
-
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 forparams
- 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 referenceres
- response received from the Invoke callremoteAgent
- 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 forparams
- 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 dataparams
- 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
-
-