🔀 Merge branch “release-80”
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / plugin / event / ReceivedReplyEvent.java
1 /*
2  * Sone - ReceivedReplyEvent.java - Copyright Â© 2013–2019 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.sone.freenet.plugin.event;
19
20 import net.pterodactylus.sone.freenet.plugin.PluginConnector;
21 import freenet.support.SimpleFieldSet;
22 import freenet.support.api.Bucket;
23
24 /**
25  * Event that signals that a plugin reply was received.
26  */
27 public class ReceivedReplyEvent {
28
29         /** The connector that received the reply. */
30         private final PluginConnector pluginConnector;
31
32         /** The name of the plugin that sent the reply. */
33         private final String pluginName;
34
35         /** The identifier of the initial request. */
36         private final String identifier;
37
38         /** The fields containing the reply. */
39         private final SimpleFieldSet fieldSet;
40
41         /** The optional reply data. */
42         private final Bucket data;
43
44         /**
45          * Creates a new â€śreply received” event.
46          *
47          * @param pluginConnector
48          *            The connector that received the event
49          * @param pluginName
50          *            The name of the plugin that sent the reply
51          * @param identifier
52          *            The identifier of the initial request
53          * @param fieldSet
54          *            The fields containing the reply
55          * @param data
56          *            The optional data of the reply
57          */
58         public ReceivedReplyEvent(PluginConnector pluginConnector, String pluginName, String identifier, SimpleFieldSet fieldSet, Bucket data) {
59                 this.pluginConnector = pluginConnector;
60                 this.pluginName = pluginName;
61                 this.identifier = identifier;
62                 this.fieldSet = fieldSet;
63                 this.data = data;
64         }
65
66         //
67         // ACCESSORS
68         //
69
70         /**
71          * Returns the plugin connector that received the reply.
72          *
73          * @return The plugin connector that received the reply
74          */
75         public PluginConnector pluginConnector() {
76                 return pluginConnector;
77         }
78
79         /**
80          * Returns the name of the plugin that sent the reply.
81          *
82          * @return The name of the plugin that sent the reply
83          */
84         public String pluginName() {
85                 return pluginName;
86         }
87
88         /**
89          * Returns the identifier of the initial request.
90          *
91          * @return The identifier of the initial request
92          */
93         public String identifier() {
94                 return identifier;
95         }
96
97         /**
98          * Returns the fields containing the reply.
99          *
100          * @return The fields containing the reply
101          */
102         public SimpleFieldSet fieldSet() {
103                 return fieldSet;
104         }
105
106         /**
107          * Returns the optional data of the reply.
108          *
109          * @return The optional data of the reply (may be {@code null})
110          */
111         public Bucket data() {
112                 return data;
113         }
114
115 }