Add constructor with identifier, add methods to set type and text
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 18:39:43 +0000 (20:39 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 18:50:50 +0000 (20:50 +0200)
src/main/java/net/pterodactylus/fcp/ModifyPeerNote.java
src/main/java/net/pterodactylus/fcp/PeerNoteType.java [new file with mode: 0644]

index 27927aa..485467d 100644 (file)
@@ -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 (file)
index 0000000..7ebede3
--- /dev/null
@@ -0,0 +1,23 @@
+package net.pterodactylus.fcp;
+
+/**
+ * All possible peer note types.
+ *
+ * @author <a href="mailto:bombe@freenetproject.org">David ‘Bombe’ Roden</a>
+ */
+public enum PeerNoteType {
+
+       PRIVATE_DARKNET_COMMENT(1);
+
+       private int value;
+
+       PeerNoteType(int value) {
+               this.value = value;
+       }
+
+       @Override
+       public String toString() {
+               return String.valueOf(value);
+       }
+
+}