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 com.google.common.base.Function;
23 * Defines a channel in a {@link Network}.
25 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
27 public class Channel {
29 /** Function to convert a channel to its network. */
30 public static final Function<Channel, Network> TO_NETWORK = new Function<Channel, Network>() {
32 public Network apply(Channel channel) {
33 return channel.network();
37 /** The network this channel belongs to. */
38 private final Network network;
40 /** The name of the channel. */
41 private final String name;
44 * Creates a new channel.
47 * The network the channel belongs to
49 * The name of the channel
51 public Channel(Network network, String name) {
52 this.network = network;
61 * Returns the network this channel belongs to
63 * @return The network this channel belongs to
65 public Network network() {
70 * Returns the name of this channel.
72 * @return The name of this channel
74 public String name() {
83 public boolean equals(Object object) {
84 if (!(object instanceof Channel)) {
87 Channel channel = (Channel) object;
88 if (!network().equals(channel.network())) {
91 if (!name().equalsIgnoreCase(channel.name())) {
98 public int hashCode() {
99 return network().hashCode() ^ name().hashCode();