tidied create and update args

This commit is contained in:
mattbradburyr3 2023-01-29 19:33:56 +00:00
parent 4c58c0b0a8
commit 18eebf6ab6
5 changed files with 42 additions and 27 deletions

View File

@ -3,12 +3,18 @@ package com.r3.developers.csdetemplate.utxoexample.workflows;
import net.corda.v5.base.annotations.ConstructorForDeserialization; import net.corda.v5.base.annotations.ConstructorForDeserialization;
import net.corda.v5.base.annotations.CordaSerializable; 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{ public class CreateNewChatFlowArgs{
// Serialisation service requires a default constructor
public CreateNewChatFlowArgs() {} 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) { public CreateNewChatFlowArgs(String chatName, String message, String otherMember) {
this.chatName = chatName; this.chatName = chatName;
this.message = message; this.message = message;
@ -19,27 +25,25 @@ public class CreateNewChatFlowArgs{
return chatName; return chatName;
} }
public void setChatName(String chatName) { // public void setChatName(String chatName) {
this.chatName = chatName; // this.chatName = chatName;
} // }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { // public void setMessage(String message) {
this.message = message; // this.message = message;
} // }
public String getOtherMember() { public String getOtherMember() {
return otherMember; return otherMember;
} }
public void setOtherMember(String otherMember) { // public void setOtherMember(String otherMember) {
this.otherMember = otherMember; // this.otherMember = otherMember;
} // }
public String chatName;
public String message;
public String otherMember;
} }

View File

@ -17,6 +17,15 @@ import java.util.List;
public class FinalizeChatSubFlow implements SubFlow<String> { public class FinalizeChatSubFlow implements SubFlow<String> {
// these need to be private + good practice is to declare them at the start of the class // 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 UtxoSignedTransaction signedTransaction;
private final MemberX500Name otherMember; private final MemberX500Name otherMember;

View File

@ -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 // The Kotlin helper functions are more simple because Kotlin supports functions which are in the package but
// not in a class. // not in a class.
public final class ResponderValidationHelpers { //public final class ResponderValidationHelpers {
// public final static List<String> bannedWords = Arrays.asList("banana", "apple", "pear"); // public final static List<String> bannedWords = Arrays.asList("banana", "apple", "pear");
// //
// @Suspendable // @Suspendable
@ -28,5 +28,5 @@ public final class ResponderValidationHelpers {
// This class just introduces a scope for some helper functions and should not be instantiated. // This class just introduces a scope for some helper functions and should not be instantiated.
// private ResponderValidationHelpers() {} // private ResponderValidationHelpers() {}
} //}

View File

@ -75,7 +75,7 @@ public class UpdateChatFlow implements RPCStartableFlow {
List<StateAndRef<ChatState>> chatStates = ledgerService.findUnconsumedStatesByType(ChatState.class); List<StateAndRef<ChatState>> chatStates = ledgerService.findUnconsumedStatesByType(ChatState.class);
List<StateAndRef<ChatState>> chatStatesWithId = chatStates.stream() List<StateAndRef<ChatState>> chatStatesWithId = chatStates.stream()
.filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList()); .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<ChatState> stateAndRef = chatStatesWithId.get(0); StateAndRef<ChatState> stateAndRef = chatStatesWithId.get(0);

View File

@ -4,11 +4,14 @@ import net.corda.v5.base.annotations.ConstructorForDeserialization;
import net.corda.v5.base.annotations.CordaSerializable; import net.corda.v5.base.annotations.CordaSerializable;
import java.util.UUID; import java.util.UUID;
@CordaSerializable //@CordaSerializable
public class UpdateChatFlowArgs { public class UpdateChatFlowArgs {
public UpdateChatFlowArgs() {} public UpdateChatFlowArgs() {}
@ConstructorForDeserialization private UUID id;
private String message;
// @ConstructorForDeserialization
public UpdateChatFlowArgs(UUID id, String message) { public UpdateChatFlowArgs(UUID id, String message) {
this.id = id; this.id = id;
this.message = message; this.message = message;
@ -18,19 +21,18 @@ public class UpdateChatFlowArgs {
return id; return id;
} }
public void setId(UUID id) { // public void setId(UUID id) {
this.id = id; // this.id = id;
} // }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { // public void setMessage(String message) {
this.message = message; // this.message = message;
} // }
public UUID id;
public String message;
} }