X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FPeer.java;h=68b970b56d4eabed4e68ea2c5731180b933e6736;hb=91c14e9e7fcc032dbe86073b0210eb2745e3f28a;hp=9fd966518e05fbaa2bb39da7b34b88dbd59d9e4e;hpb=dcf4c99e61e5b926203f3f24f4773dc3e9d52f21;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/Peer.java b/src/net/pterodactylus/fcp/Peer.java index 9fd9665..68b970b 100644 --- a/src/net/pterodactylus/fcp/Peer.java +++ b/src/net/pterodactylus/fcp/Peer.java @@ -19,6 +19,11 @@ package net.pterodactylus.fcp; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + /** * The “Peer” reply by the node contains information about a peer. * @@ -183,6 +188,21 @@ public class Peer extends BaseMessage { } /** + * Returns all volatile fields from the message. + * + * @return All volatile files + */ + public Map getVolatileFields() { + Map volatileFields = new HashMap(); + for (Entry field : getFields().entrySet()) { + if (field.getKey().startsWith("volatile.")) { + volatileFields.put(field.getKey(), field.getValue()); + } + } + return Collections.unmodifiableMap(volatileFields); + } + + /** * Returns one of the volatile fields from the message. The given field name * is prepended with “volatile.” so if you want to get the value of the * field with the name “volatile.status” you only need to specify “status”. @@ -197,6 +217,21 @@ public class Peer extends BaseMessage { } /** + * Returns all metadata fields from the message. + * + * @return All volatile files + */ + public Map getMetadataFields() { + Map metadataFields = new HashMap(); + for (Entry field : getFields().entrySet()) { + if (field.getKey().startsWith("metadata.")) { + metadataFields.put(field.getKey(), field.getValue()); + } + } + return Collections.unmodifiableMap(metadataFields); + } + + /** * Returns one of the metadata fields from the message. The given field name * is prepended with “metadata.” so if you want to get the value of the * field with the name “metadata.timeLastRoutable” you only need to specify