Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/java/io/eigr/spawn/api/ActorRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected static ActorRef of(SpawnClient client, String system, String name, Str
* @return an Optional containing, or not, the response object to the Action call
* @since 0.0.1
*/
public <T extends GeneratedMessageV3> Optional<Object> invoke(String action, Class<T> outputType) throws Exception {
Optional<Object> res = invokeActor(action, Empty.getDefaultInstance(), outputType, Optional.empty());
public <T extends GeneratedMessageV3> Optional<T> invoke(String action, Class<T> outputType) throws Exception {
Optional<T> res = invokeActor(action, Empty.getDefaultInstance(), outputType, Optional.empty());
if(res.isPresent() ){
return Optional.of(outputType.cast(res.get()));
}
Expand All @@ -111,8 +111,8 @@ public <T extends GeneratedMessageV3> Optional<Object> invoke(String action, Cl
* @return an Optional containing, or not, the response object to the Action call
* @since 0.0.1
*/
public <T extends GeneratedMessageV3> Optional<Object> invoke(String action, Class<T> outputType, InvocationOpts opts) throws Exception {
Optional<Object> res = invokeActor(action, Empty.getDefaultInstance(), outputType, Optional.ofNullable(opts));
public <T extends GeneratedMessageV3> Optional<T> invoke(String action, Class<T> outputType, InvocationOpts opts) throws Exception {
Optional<T> res = invokeActor(action, Empty.getDefaultInstance(), outputType, Optional.ofNullable(opts));
if(res.isPresent() ){
return Optional.of(outputType.cast(res.get()));
}
Expand All @@ -130,8 +130,8 @@ public <T extends GeneratedMessageV3> Optional<Object> invoke(String action, Cl
* @return an Optional containing, or not, the response object to the Action call
* @since 0.0.1
*/
public <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<Object> invoke(String action, S value, Class<T> outputType) throws Exception {
Optional<Object> res = invokeActor(action, value, outputType, Optional.empty());
public <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<T> invoke(String action, S value, Class<T> outputType) throws Exception {
Optional<T> res = invokeActor(action, value, outputType, Optional.empty());
if(res.isPresent() ){
return Optional.of(outputType.cast(res.get()));
}
Expand All @@ -151,8 +151,8 @@ public <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<Obj
* @return an Optional containing, or not, the response object to the Action call
* @since 0.0.1
*/
public <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<Object> invoke(String action, S value, Class<T> outputType, InvocationOpts opts) throws Exception {
Optional<Object> res = invokeActor(action, value, outputType, Optional.ofNullable(opts));
public <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<T> invoke(String action, S value, Class<T> outputType, InvocationOpts opts) throws Exception {
Optional<T> res = invokeActor(action, value, outputType, Optional.ofNullable(opts));
if(res.isPresent() ){
return Optional.of(outputType.cast(res.get()));
}
Expand Down Expand Up @@ -248,7 +248,7 @@ public boolean isUnNamedActor() {
return false;
}

private <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<Object> invokeActor(
private <T extends GeneratedMessageV3, S extends GeneratedMessageV3> Optional<T> invokeActor(
String cmd, S argument, Class<T> outputType, Optional<InvocationOpts> options) throws Exception {
Protocol.InvocationRequest.Builder invocationRequestBuilder = Protocol.InvocationRequest.newBuilder();

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/eigr/spawn/SpawnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public void testApp() throws Exception {
.setLanguage("erlang")
.build();

Optional<Object> maybeReply =
Optional<Actor.Reply> maybeReply =
joeActor.invoke("setLanguage", msg, Actor.Reply.class);

if (maybeReply.isPresent()) {
Actor.Reply reply = (Actor.Reply) maybeReply.get();
Actor.Reply reply = maybeReply.get();
assertNotNull(reply);
assertEquals("Hello From Java", reply.getResponse());
}
Expand Down