From 18eebf6ab6fbc9510ec2ea18b644f28e45ae4793 Mon Sep 17 00:00:00 2001 From: mattbradburyr3 Date: Sun, 29 Jan 2023 19:33:56 +0000 Subject: [PATCH] tidied create and update args --- .../workflows/CreateNewChatFlowArgs.java | 32 +++++++++++-------- .../workflows/FinalizeChatSubFlow.java | 9 ++++++ .../workflows/ResponderValidationHelpers.java | 4 +-- .../utxoexample/workflows/UpdateChatFlow.java | 2 +- .../workflows/UpdateChatFlowArgs.java | 22 +++++++------ 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlowArgs.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlowArgs.java index 7c2fc62..f604a5e 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlowArgs.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlowArgs.java @@ -3,12 +3,18 @@ package com.r3.developers.csdetemplate.utxoexample.workflows; import net.corda.v5.base.annotations.ConstructorForDeserialization; import net.corda.v5.base.annotations.CordaSerializable; -@CordaSerializable +//@CordaSerializable - we're not sending it down the wire so we don't need this. public class CreateNewChatFlowArgs{ + // Serialisation service requires a default constructor public CreateNewChatFlowArgs() {} - @ConstructorForDeserialization + private String chatName; + private String message; + private String otherMember; + + +// @ConstructorForDeserialization // don't appear to need this public CreateNewChatFlowArgs(String chatName, String message, String otherMember) { this.chatName = chatName; this.message = message; @@ -19,27 +25,25 @@ public class CreateNewChatFlowArgs{ return chatName; } - public void setChatName(String chatName) { - this.chatName = chatName; - } +// public void setChatName(String chatName) { +// this.chatName = chatName; +// } public String getMessage() { return message; } - public void setMessage(String message) { - this.message = message; - } +// public void setMessage(String message) { +// this.message = message; +// } public String getOtherMember() { return otherMember; } - public void setOtherMember(String otherMember) { - this.otherMember = otherMember; - } +// public void setOtherMember(String otherMember) { +// this.otherMember = otherMember; +// } + - public String chatName; - public String message; - public String otherMember; } \ No newline at end of file diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java index 2ab4ff5..08d6edc 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java @@ -17,6 +17,15 @@ import java.util.List; public class FinalizeChatSubFlow implements SubFlow { // these need to be private + good practice is to declare them at the start of the class + // java code conventions: + /* + * According to Code Conventions for the Java Programming Language, the parts of a class or interface declaration should appear in the following order: + * Class (static) variables. First the public class variables, then protected, then package level (no access modifier), and then private. + * Instance variables. First the public class variables, then protected, then package level (no access modifier), and then private. + * Constructors + * Methods + * */ + private final UtxoSignedTransaction signedTransaction; private final MemberX500Name otherMember; diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/ResponderValidationHelpers.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/ResponderValidationHelpers.java index 91e35dc..766903d 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/ResponderValidationHelpers.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/ResponderValidationHelpers.java @@ -12,7 +12,7 @@ import java.util.List; // The Kotlin helper functions are more simple because Kotlin supports functions which are in the package but // not in a class. -public final class ResponderValidationHelpers { +//public final class ResponderValidationHelpers { // public final static List bannedWords = Arrays.asList("banana", "apple", "pear"); // // @Suspendable @@ -28,5 +28,5 @@ public final class ResponderValidationHelpers { // This class just introduces a scope for some helper functions and should not be instantiated. // private ResponderValidationHelpers() {} -} +//} diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java index 069fd67..932d629 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java @@ -75,7 +75,7 @@ public class UpdateChatFlow implements RPCStartableFlow { List> chatStates = ledgerService.findUnconsumedStatesByType(ChatState.class); List> chatStatesWithId = chatStates.stream() .filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList()); - if (chatStatesWithId.size() != 1) throw new CordaRuntimeException("Multiple or zero Chat states with id " + flowArgs.id + " found"); + if (chatStatesWithId.size() != 1) throw new CordaRuntimeException("Multiple or zero Chat states with id " + flowArgs.getId() + " found"); StateAndRef stateAndRef = chatStatesWithId.get(0); diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlowArgs.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlowArgs.java index 4c91112..440ac2d 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlowArgs.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlowArgs.java @@ -4,11 +4,14 @@ import net.corda.v5.base.annotations.ConstructorForDeserialization; import net.corda.v5.base.annotations.CordaSerializable; import java.util.UUID; -@CordaSerializable +//@CordaSerializable public class UpdateChatFlowArgs { public UpdateChatFlowArgs() {} - @ConstructorForDeserialization + private UUID id; + private String message; + +// @ConstructorForDeserialization public UpdateChatFlowArgs(UUID id, String message) { this.id = id; this.message = message; @@ -18,19 +21,18 @@ public class UpdateChatFlowArgs { return id; } - public void setId(UUID id) { - this.id = id; - } +// public void setId(UUID id) { +// this.id = id; +// } public String getMessage() { return message; } - public void setMessage(String message) { - this.message = message; - } +// public void setMessage(String message) { +// this.message = message; +// } + - public UUID id; - public String message; }