Add Freenet plugin and WoT subprojects
[fwot.git] / plugin / src / main / java / net / pterodactylus / freenet / plugin / event / ReceivedReplyEvent.java
1 /*
2  * fplugin - ReceivedReplyEvent.java - Copyright © 2013–2015 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.freenet.plugin.event;
19
20 import net.pterodactylus.freenet.plugin.PluginConnector;
21
22 import freenet.support.SimpleFieldSet;
23 import freenet.support.api.Bucket;
24
25 /**
26  * Event that signals that a plugin reply was received.
27  *
28  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29  */
30 public class ReceivedReplyEvent {
31
32         /** The connector that received the reply. */
33         private final PluginConnector pluginConnector;
34
35         /** The name of the plugin that sent the reply. */
36         private final String pluginName;
37
38         /** The identifier of the initial request. */
39         private final String identifier;
40
41         /** The fields containing the reply. */
42         private final SimpleFieldSet fieldSet;
43
44         /** The optional reply data. */
45         private final Bucket data;
46
47         /**
48          * Creates a new “reply received” event.
49          *
50          * @param pluginConnector
51          *              The connector that received the event
52          * @param pluginName
53          *              The name of the plugin that sent the reply
54          * @param identifier
55          *              The identifier of the initial request
56          * @param fieldSet
57          *              The fields containing the reply
58          * @param data
59          *              The optional data of the reply
60          */
61         public ReceivedReplyEvent(PluginConnector pluginConnector, String pluginName, String identifier,
62                         SimpleFieldSet fieldSet, Bucket data) {
63                 this.pluginConnector = pluginConnector;
64                 this.pluginName = pluginName;
65                 this.identifier = identifier;
66                 this.fieldSet = fieldSet;
67                 this.data = data;
68         }
69
70         //
71         // ACCESSORS
72         //
73
74         /**
75          * Returns the plugin connector that received the reply.
76          *
77          * @return The plugin connector that received the reply
78          */
79         public PluginConnector pluginConnector() {
80                 return pluginConnector;
81         }
82
83         /**
84          * Returns the name of the plugin that sent the reply.
85          *
86          * @return The name of the plugin that sent the reply
87          */
88         public String pluginName() {
89                 return pluginName;
90         }
91
92         /**
93          * Returns the identifier of the initial request.
94          *
95          * @return The identifier of the initial request
96          */
97         public String identifier() {
98                 return identifier;
99         }
100
101         /**
102          * Returns the fields containing the reply.
103          *
104          * @return The fields containing the reply
105          */
106         public SimpleFieldSet fieldSet() {
107                 return fieldSet;
108         }
109
110         /**
111          * Returns the optional data of the reply.
112          *
113          * @return The optional data of the reply (may be {@code null})
114          */
115         public Bucket data() {
116                 return data;
117         }
118
119 }