Split command reader into separate commands.
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / ui / stdin / State.java
1 /*
2  * XdccDownloader - State.java - Copyright © 2013 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.xdcc.ui.stdin;
19
20 import java.util.List;
21
22 import net.pterodactylus.irc.Connection;
23 import net.pterodactylus.xdcc.data.Download;
24
25 import com.google.common.collect.Lists;
26
27 /**
28  * Container for the current state of the command reader.
29  *
30  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31  */
32 public class State {
33
34         /** The last connections displayed. */
35         private final List<Connection> lastConnections;
36
37         /** The last results displayed. */
38         private final List<Result> lastResults;
39
40         /** The last downloads displayed. */
41         private final List<Download> lastDownloads;
42
43         /** Creates a new empty state. */
44         public State() {
45                 this(Lists.<Connection>newArrayList(), Lists.<Result>newArrayList(), Lists.<Download>newArrayList());
46         }
47
48         /**
49          * Creates a new state.
50          *
51          * @param lastConnections
52          *              The last connections
53          * @param lastResults
54          *              The last results
55          * @param lastDownloads
56          *              The last downloads
57          */
58         State(List<Connection> lastConnections, List<Result> lastResults, List<Download> lastDownloads) {
59                 this.lastConnections = lastConnections;
60                 this.lastResults = lastResults;
61                 this.lastDownloads = lastDownloads;
62         }
63
64         //
65         // ACCESSORS
66         //
67
68         /**
69          * Returns the last connections displayed.
70          *
71          * @return The last connections displayed
72          */
73         public List<Connection> getLastConnections() {
74                 return lastConnections;
75         }
76
77         /**
78          * Returns the last results displayed.
79          *
80          * @return The last results displayed
81          */
82         public List<Result> getLastResults() {
83                 return lastResults;
84         }
85
86         /**
87          * Returns the last downloads displayed.
88          *
89          * @return The last downloads displayed
90          */
91         public List<Download> getLastDownloads() {
92                 return lastDownloads;
93         }
94
95         //
96         // MUTATORS
97         //
98
99         /**
100          * Returns a new state with the given last connections and the last downloads
101          * and results of this state.
102          *
103          * @param lastConnections
104          *              The new last connections displayed
105          * @return The new state
106          */
107         public State setLastConnections(List<Connection> lastConnections) {
108                 return new State(lastConnections, lastResults, lastDownloads);
109         }
110
111         /**
112          * Returns a new state with the given last results and the last downloads and
113          * connections of this state.
114          *
115          * @param lastResults
116          *              The new last results displayed
117          * @return The new state
118          */
119         public State setLastResults(List<Result> lastResults) {
120                 return new State(lastConnections, lastResults, lastDownloads);
121         }
122
123         /**
124          * Returns a new state with the given last downloads and the last connections
125          * and results of this state.
126          *
127          * @param lastDownloads
128          *              The new last downloads displayed
129          * @return The new state
130          */
131         public State setLastDownloads(List<Download> lastDownloads) {
132                 return new State(lastConnections, lastResults, lastDownloads);
133         }
134
135 }