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.ArrayList;
21 import java.util.List;
23 import net.pterodactylus.irc.Connection;
24 import net.pterodactylus.xdcc.data.Download;
26 import com.google.common.collect.Lists;
29 * Container for the current state of the command reader.
31 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
35 /** The last connections displayed. */
36 private final List<Connection> lastConnections;
38 /** The last results displayed. */
39 private final List<Result> lastResults;
41 /** The last downloads displayed. */
42 private final List<Download> lastDownloads;
44 private final List<Download> lastFailedDownloads;
46 /** Creates a new empty state. */
48 this(Lists.<Connection>newArrayList(), Lists.<Result>newArrayList(), Lists.<Download>newArrayList(), new ArrayList<>());
52 * Creates a new state.
54 * @param lastConnections
55 * The last connections
58 * @param lastDownloads
59 * @param lastFailedDownloads
60 * The last failed downloads shown
62 State(List<Connection> lastConnections, List<Result> lastResults, List<Download> lastDownloads, List<Download> lastFailedDownloads) {
63 this.lastConnections = lastConnections;
64 this.lastResults = lastResults;
65 this.lastDownloads = lastDownloads;
66 this.lastFailedDownloads = lastFailedDownloads;
74 * Returns the last connections displayed.
76 * @return The last connections displayed
78 public List<Connection> getLastConnections() {
79 return lastConnections;
83 * Returns the last results displayed.
85 * @return The last results displayed
87 public List<Result> getLastResults() {
92 * Returns the last downloads displayed.
94 * @return The last downloads displayed
96 public List<Download> getLastDownloads() {
100 public List<Download> getLastFailedDownloads() {
101 return lastFailedDownloads;
109 * Returns a new state with the given last connections and the last downloads
110 * and results of this state.
112 * @param lastConnections
113 * The new last connections displayed
114 * @return The new state
116 public State setLastConnections(List<Connection> lastConnections) {
117 return new State(lastConnections, lastResults, lastDownloads, lastFailedDownloads);
121 * Returns a new state with the given last results and the last downloads and
122 * connections of this state.
125 * The new last results displayed
126 * @return The new state
128 public State setLastResults(List<Result> lastResults) {
129 return new State(lastConnections, lastResults, lastDownloads, lastFailedDownloads);
133 * Returns a new state with the given last downloads and the last connections
134 * and results of this state.
136 * @param lastDownloads
137 * The new last downloads displayed
138 * @return The new state
140 public State setLastDownloads(List<Download> lastDownloads) {
141 return new State(lastConnections, lastResults, lastDownloads, lastFailedDownloads);
144 public State setLastFailedDownloads(List<Download> lastFailedDownloads) {
145 return new State(lastConnections, lastResults, lastDownloads, lastFailedDownloads);