2 * XdccDownloader - Channel.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.data;
20 import static java.lang.String.format;
22 import com.google.common.base.Function;
25 * Defines a channel in a {@link Network}.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29 public class Channel {
31 /** The network this channel belongs to. */
32 private final Network network;
34 /** The name of the channel. */
35 private final String name;
38 * Creates a new channel.
41 * The network the channel belongs to
43 * The name of the channel
45 public Channel(Network network, String name) {
46 this.network = network;
55 * Returns the network this channel belongs to
57 * @return The network this channel belongs to
59 public Network network() {
64 * Returns the name of this channel.
66 * @return The name of this channel
68 public String name() {
77 public boolean equals(Object object) {
78 if (!(object instanceof Channel)) {
81 Channel channel = (Channel) object;
82 if (!network().equals(channel.network())) {
85 if (!name().equalsIgnoreCase(channel.name())) {
92 public int hashCode() {
93 return network().hashCode() ^ name().hashCode();
97 public String toString() {
98 return format("%s/%s", name(), network().name());