2 * XdccDownloader - State.java - Copyright © 2013 David Roden
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.
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.
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/>.
18 package net.pterodactylus.xdcc.ui.stdin;
20 import java.util.List;
22 import net.pterodactylus.irc.Connection;
23 import net.pterodactylus.xdcc.data.Download;
25 import com.google.common.collect.Lists;
28 * Container for the current state of the command reader.
30 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34 /** The last connections displayed. */
35 private final List<Connection> lastConnections;
37 /** The last results displayed. */
38 private final List<Result> lastResults;
40 /** The last downloads displayed. */
41 private final List<Download> lastDownloads;
43 /** Creates a new empty state. */
45 this(Lists.<Connection>newArrayList(), Lists.<Result>newArrayList(), Lists.<Download>newArrayList());
49 * Creates a new state.
51 * @param lastConnections
52 * The last connections
55 * @param lastDownloads
58 State(List<Connection> lastConnections, List<Result> lastResults, List<Download> lastDownloads) {
59 this.lastConnections = lastConnections;
60 this.lastResults = lastResults;
61 this.lastDownloads = lastDownloads;
69 * Returns the last connections displayed.
71 * @return The last connections displayed
73 public List<Connection> getLastConnections() {
74 return lastConnections;
78 * Returns the last results displayed.
80 * @return The last results displayed
82 public List<Result> getLastResults() {
87 * Returns the last downloads displayed.
89 * @return The last downloads displayed
91 public List<Download> getLastDownloads() {
100 * Returns a new state with the given last connections and the last downloads
101 * and results of this state.
103 * @param lastConnections
104 * The new last connections displayed
105 * @return The new state
107 public State setLastConnections(List<Connection> lastConnections) {
108 return new State(lastConnections, lastResults, lastDownloads);
112 * Returns a new state with the given last results and the last downloads and
113 * connections of this state.
116 * The new last results displayed
117 * @return The new state
119 public State setLastResults(List<Result> lastResults) {
120 return new State(lastConnections, lastResults, lastDownloads);
124 * Returns a new state with the given last downloads and the last connections
125 * and results of this state.
127 * @param lastDownloads
128 * The new last downloads displayed
129 * @return The new state
131 public State setLastDownloads(List<Download> lastDownloads) {
132 return new State(lastConnections, lastResults, lastDownloads);