Class Unpack
java.lang.Object
org.hansken.plugin.extraction.runtime.grpc.common.Unpack
Utility class to convert from gRPC messages to their native Java or plugin API counterparts.
For the other way around, see
Pack.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends com.google.protobuf.Message>
TUpack anAnycontaining a message of given message type.static Authorstatic byte[]bytes(com.google.protobuf.Any any) Convert primitiveRpcBytesmessage to the native Javabyte[]counterpart.static RpcFinishfinish(com.google.protobuf.Any any) Unpack anAnycontaining anRpcFinishmessage.genericList(RpcList list) Unpacks a generic non-homogenous list into a native JavaList.genericMap(RpcMap map) Unpacks a generic non-homogenous map into a native JavaMap.static MaturityLevelmaturityLevel(RpcMaturity maturity) Convert givenRpcMaturityto theirMaturityLevelcounterpart.static StringpluginApiVersion(RpcPluginInfo rpcPluginInfo) Returns the API version contained in theRpcPluginInfoinstance.static PluginIdpluginId(RpcPluginIdentifier rpcPluginIdentifier) static PluginInfopluginInfo(RpcPluginInfo rpcPluginInfo) Convert givenRpcPluginInfoto theirPluginInfocounterpart.static PluginResourcespluginResources(RpcPluginResources rpcPluginResources) Convert givenRpcPluginResourcesto theirPluginResourcescounterpart.static PluginTypepluginType(RpcPluginType type) Convert givenRpcPluginTypeto theirPluginTypecounterpart.static Objectprimitive(com.google.protobuf.Any any) Convert given primitive message to their native Java counterpart.static TraceSearcher.SearchScopesearchScope(RpcSearchScope scope) static RpcStartstart(com.google.protobuf.Any any) Unpack anAnycontaining anRpcStartmessage.static Trace.Tracelettracelet(RpcTracelet rpcTracelet) Convert givenRpcTraceletto theirTrace.Traceletcounterpart.static List<DataTransformation> transformations(List<RpcTransformation> rpcDataTransformations) static ObjecttransformerArgument(RpcTransformerArgument response) Convert aRpcTransformerArgumentinto a Java native type.static RpcTransformerArgumenttransformerResponse(RpcTransformerResponse response) Retrieve the response value fromRpcTransformerResponse.static List<TransformerLabel> transformers(List<RpcTransformer> transformers)
-
Method Details
-
start
Unpack anAnycontaining anRpcStartmessage.- Parameters:
any- the any to unpack- Returns:
- the start message
- Throws:
IllegalArgumentException- if the any does not contain a message of typeRpcStart
-
finish
Unpack anAnycontaining anRpcFinishmessage.- Parameters:
any- the any to unpack- Returns:
- the finish message
- Throws:
IllegalArgumentException- if the any does not contain a message of typeRpcFinish
-
any
public static <T extends com.google.protobuf.Message> T any(com.google.protobuf.Any any, Class<T> messageType) Upack anAnycontaining a message of given message type.- Type Parameters:
T- the type of the message contained in the any- Parameters:
any- the any to unpackmessageType- class of the message contained in the any- Returns:
- the message
- Throws:
IllegalArgumentException- if the any does not contain a message of given type
-
primitive
Convert given primitive message to their native Java counterpart.- Parameters:
any- the any container of the primitive message- Returns:
- the unpacked primitive
- Throws:
IllegalArgumentException- if the any is not of an expected primitive message type
-
bytes
public static byte[] bytes(com.google.protobuf.Any any) Convert primitiveRpcBytesmessage to the native Javabyte[]counterpart.- Parameters:
any- the any container of the primitive rpc bytes message- Returns:
- the packed bytes
- Throws:
IllegalArgumentException- if given any does not contain an RpcBytes message
-
pluginInfo
Convert givenRpcPluginInfoto theirPluginInfocounterpart.The API version that is available in
RpcPluginInfois not returned in thePluginInfoinstance, to get this value usepluginApiVersion(RpcPluginInfo).- Parameters:
rpcPluginInfo- the plugin info to convert- Returns:
- the converted info
- Throws:
IllegalArgumentException- when a property of given info is invalid as per thePluginInfo.Buildermethods
-
pluginId
-
transformers
-
pluginApiVersion
Returns the API version contained in theRpcPluginInfoinstance.- Parameters:
rpcPluginInfo- the plugin info that contains the API version- Returns:
- API version
-
tracelet
Convert givenRpcTraceletto theirTrace.Traceletcounterpart.- Parameters:
rpcTracelet- the info to convert- Returns:
- the converted info
- Throws:
IllegalArgumentException- when a property of given info is invalid as per thePluginInfo.Buildermethods
-
author
- Parameters:
author- the author to convert- Returns:
- the converted author
- Throws:
IllegalArgumentException- when a property of given author is invalid as per theAuthor.Buildermethods
-
maturityLevel
Convert givenRpcMaturityto theirMaturityLevelcounterpart.- Parameters:
maturity- the maturity to convert- Returns:
- the converted maturity
- Throws:
IllegalArgumentException- when the given maturity is not mappable
-
transformerResponse
Retrieve the response value fromRpcTransformerResponse. Currently only primitives are supported as defined in TransformerArgument.allowedTypes.- Parameters:
response- TheRpcTransformerResponsethat we want to retrieve the response value from.- Returns:
- The response value that is stored within the
RpcTransformerResponse}.
-
genericMap
Unpacks a generic non-homogenous map into a native JavaMap.- Parameters:
map- TheRpcMapthat should be unpacked.- Returns:
- The unpacked map.
-
genericList
Unpacks a generic non-homogenous list into a native JavaList.- Parameters:
list- TheRpcListthat should be unpacked.- Returns:
- The unpacked list.
-
transformerArgument
Convert aRpcTransformerArgumentinto a Java native type. Currently only primitives are supported as defined in PRIMITIVE_UNPACKER.- Parameters:
response- TheRpcTransformerArgumentthat we want to unpack into a Java native value- Returns:
- The response value that is stored within the
RpcTransformerResponse}.
-
pluginType
Convert givenRpcPluginTypeto theirPluginTypecounterpart.- Parameters:
type- the type to convert- Returns:
- the converted type
- Throws:
IllegalArgumentException- when the given type is not mappable
-
pluginResources
Convert givenRpcPluginResourcesto theirPluginResourcescounterpart.- Parameters:
rpcPluginResources- the rpc plugin resources to convert- Returns:
- the converted plugin resources
-
transformations
public static List<DataTransformation> transformations(List<RpcTransformation> rpcDataTransformations) -
searchScope
-