From 74b8a73a378fd921b0bb5cae88fd1e8e071840bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 14 Jul 2015 20:39:43 +0200 Subject: [PATCH 1/1] Add constructor with identifier, add methods to set type and text --- .../java/net/pterodactylus/fcp/ModifyPeerNote.java | 31 ++++++++++++---------- .../java/net/pterodactylus/fcp/PeerNoteType.java | 23 ++++++++++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 src/main/java/net/pterodactylus/fcp/PeerNoteType.java diff --git a/src/main/java/net/pterodactylus/fcp/ModifyPeerNote.java b/src/main/java/net/pterodactylus/fcp/ModifyPeerNote.java index 27927aa..485467d 100644 --- a/src/main/java/net/pterodactylus/fcp/ModifyPeerNote.java +++ b/src/main/java/net/pterodactylus/fcp/ModifyPeerNote.java @@ -25,20 +25,15 @@ package net.pterodactylus.fcp; */ public class ModifyPeerNote extends FcpMessage { - /** - * Creates a new “ModifyPeerNote” request that changes peer note of the - * given type and node to the given text. - * - * @see PeerNote - * @param nodeIdentifier - * The identifier of the node, i.e. name, identity, or IP - * address and port - * @param noteText - * The base64-encoded text - * @param peerNoteType - * The type of the note to change, possible values are only - * {@link PeerNote#TYPE_PRIVATE_PEER_NOTE} at the moment - */ + // TODO: move base64-encoding to this class + + public ModifyPeerNote(String identifier, String nodeIdentifier) { + super("ModifyPeerNote"); + setField("Identifier", identifier); + setField("NodeIdentifier", nodeIdentifier); + } + + @Deprecated public ModifyPeerNote(String nodeIdentifier, String noteText, int peerNoteType) { super("ModifyPeerNote"); setField("NodeIdentifier", nodeIdentifier); @@ -46,4 +41,12 @@ public class ModifyPeerNote extends FcpMessage { setField("PeerNoteType", String.valueOf(peerNoteType)); } + public void setNoteText(String noteText) { + setField("NoteText", noteText); + } + + public void setPeerNoteType(PeerNoteType peerNoteType) { + setField("PeerNoteType", peerNoteType.toString()); + } + } diff --git a/src/main/java/net/pterodactylus/fcp/PeerNoteType.java b/src/main/java/net/pterodactylus/fcp/PeerNoteType.java new file mode 100644 index 0000000..7ebede3 --- /dev/null +++ b/src/main/java/net/pterodactylus/fcp/PeerNoteType.java @@ -0,0 +1,23 @@ +package net.pterodactylus.fcp; + +/** + * All possible peer note types. + * + * @author David ‘Bombe’ Roden + */ +public enum PeerNoteType { + + PRIVATE_DARKNET_COMMENT(1); + + private int value; + + PeerNoteType(int value) { + this.value = value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} -- 2.7.4