Package org.astonbitecode.j4rs.api.dtos
Class InvocationArg
- java.lang.Object
-
- org.astonbitecode.j4rs.api.dtos.InvocationArg
-
- All Implemented Interfaces:
Instance
,JsonValue
,ObjectValue
public class InvocationArg extends Object implements Instance
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONTENTS_ARRAY
The array contents should map to a List.
-
Constructor Summary
Constructors Constructor Description InvocationArg(String className, Object object)
InvocationArg(String className, String json)
InvocationArg(String className, Instance instance)
InvocationArg(Instance instance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Instance
field(String fieldName)
Retrieves the instance held under the Field fieldNameInstance
getInstance()
String
getJson()
Object
getObject()
Class<?>
getObjectClass()
String
getObjectClassName()
The type of this argument.void
initializeCallbackChannel(long channelAddress)
Initialize a callback channel for thisInstance
.Instance
invoke(String methodName, InvocationArg... args)
Invokes a method of the instance of the class that is set for thisInstance
void
invokeAsync(long functionPointerAddress, String methodName, InvocationArg... args)
Invokes asynchronously a method of the instance of the class that is set for thisInstance
.Instance
invokeStatic(String methodName, InvocationArg... args)
Invokes a static method of the class that is set for thisInstance
void
invokeToChannel(long channelAddress, String methodName, InvocationArg... args)
Invokes a method of the instance of the class that is set for thisInstance
.boolean
isSerialized()
If true, the argument is taken straight by the Java code as Object.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.astonbitecode.j4rs.api.Instance
getOrDeserializeJavaObject
-
-
-
-
Field Detail
-
CONTENTS_ARRAY
public static final String CONTENTS_ARRAY
The array contents should map to a List. This is in order to allow calls of type Arrays.asList(arg1, arg2, arg3, ...)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InvocationArg
public InvocationArg(Instance instance)
-
InvocationArg
public InvocationArg(String className, Object object) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
-
Method Detail
-
isSerialized
public boolean isSerialized()
If true, the argument is taken straight by the Java code as Object. If false, the argument is a json document that need to be deserialized to an Object.- Returns:
- The The argFrom
-
getObjectClassName
public String getObjectClassName()
The type of this argument. This is used when json objects come from Rust, in order to be mapped to proper Java Objects.- Specified by:
getObjectClassName
in interfaceObjectValue
- Returns:
- The classname
-
getInstance
public Instance getInstance()
-
getObject
public Object getObject()
- Specified by:
getObject
in interfaceObjectValue
-
getObjectClass
public Class<?> getObjectClass()
- Specified by:
getObjectClass
in interfaceObjectValue
-
invoke
public Instance invoke(String methodName, InvocationArg... args)
Description copied from interface:Instance
Invokes a method of the instance of the class that is set for thisInstance
-
invokeStatic
public Instance invokeStatic(String methodName, InvocationArg... args)
Description copied from interface:Instance
Invokes a static method of the class that is set for thisInstance
- Specified by:
invokeStatic
in interfaceInstance
- Parameters:
methodName
- The static method nameargs
- The arguments to use for invoking the static method- Returns:
- A
Instance
instance containing the result of the invocation
-
invokeAsync
public void invokeAsync(long functionPointerAddress, String methodName, InvocationArg... args)
Description copied from interface:Instance
Invokes asynchronously a method of the instance of the class that is set for thisInstance
. The result of the invocation should be provided later using the performCallback method of aNativeCallbackSupport
class. Any possible returned objects from the actual synchronous invocation of the defined method will be dropped.- Specified by:
invokeAsync
in interfaceInstance
- Parameters:
functionPointerAddress
- The address of the function pointer that will be used later in the native side in order to actually paerform the callback.methodName
- The method nameargs
- The arguments to use when invoking the callback method (the functionPointer)
-
invokeToChannel
public void invokeToChannel(long channelAddress, String methodName, InvocationArg... args)
Description copied from interface:Instance
Invokes a method of the instance of the class that is set for thisInstance
. The result of the invocation should be provided later using the doCallback method of aNativeCallbackToRustChannelSupport
class. Any possible returned objects from the actual synchronous invocation of the defined method will be dropped.- Specified by:
invokeToChannel
in interfaceInstance
- Parameters:
channelAddress
- The memory address of the channelmethodName
- The method nameargs
- The arguments
-
initializeCallbackChannel
public void initializeCallbackChannel(long channelAddress)
Description copied from interface:Instance
Initialize a callback channel for thisInstance
. The channel can be used by Java to send values to Rust using the doCallback method of aNativeCallbackToRustChannelSupport
class.- Specified by:
initializeCallbackChannel
in interfaceInstance
- Parameters:
channelAddress
- The memory address of the channel
-
-