3426ff154a76d681422719aac65322940de43d40
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Client.java
1 /*
2  * Sone - Client.java - Copyright © 2010–2016 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.sone.data;
19
20 import static com.google.common.base.Objects.equal;
21
22 import com.google.common.base.Objects;
23
24 /**
25  * Container for the client information of a {@link Sone}.
26  */
27 public class Client {
28
29         /** The name of the client. */
30         private final String name;
31
32         /** The version of the client. */
33         private final String version;
34
35         /**
36          * Creates a new client information container.
37          *
38          * @param name
39          *            The name of the client
40          * @param version
41          *            The version of the client
42          */
43         public Client(String name, String version) {
44                 this.name = name;
45                 this.version = version;
46         }
47
48         //
49         // ACCESSORS
50         //
51
52         /**
53          * Returns the name of the client.
54          *
55          * @return The name of the client
56          */
57         public String getName() {
58                 return name;
59         }
60
61         /**
62          * Returns the version of the client.
63          *
64          * @return The version of the client
65          */
66         public String getVersion() {
67                 return version;
68         }
69
70         @Override
71         public boolean equals(Object object) {
72                 if (!(object instanceof Client)) {
73                         return false;
74                 }
75                 Client client = (Client) object;
76                 return equal(getName(), client.getName()) && equal(getVersion(), client.getVersion());
77         }
78
79         @Override
80         public int hashCode() {
81                 return Objects.hashCode(name, version);
82         }
83
84 }