Update license to GPLv3, fix header comments
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / ARK.java
1 /*
2  * jFCPlib - ARK.java - Copyright © 2008–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.fcp;
19
20 /**
21  * Container for ARKs (address resolution keys).
22  *
23  * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
24  */
25 public class ARK {
26
27         /** The public URI of the ARK. */
28         private final String publicURI;
29
30         /** The private URI of the ARK. */
31         private final String privateURI;
32
33         /** The number of the ARK. */
34         private final int number;
35
36         /**
37          * Creates a new ARK with the given URI and number.
38          *
39          * @param publicURI
40          *            The public URI of the ARK
41          * @param number
42          *            The number of the ARK
43          */
44         public ARK(String publicURI, String number) {
45                 this(publicURI, null, number);
46         }
47
48         /**
49          * Creates a new ARK with the given URIs and number.
50          *
51          * @param publicURI
52          *            The public URI of the ARK
53          * @param privateURI
54          *            The private URI of the ARK
55          * @param number
56          *            The number of the ARK
57          */
58         public ARK(String publicURI, String privateURI, String number) {
59                 if ((publicURI == null) || (number == null)) {
60                         throw new NullPointerException(((publicURI == null) ? "publicURI" : "number") + " must not be null");
61                 }
62                 this.publicURI = publicURI;
63                 this.privateURI = privateURI;
64                 try {
65                         this.number = Integer.valueOf(number);
66                 } catch (NumberFormatException nfe1) {
67                         throw new IllegalArgumentException("number must be numeric", nfe1);
68                 }
69         }
70
71         /**
72          * Returns the public URI of the ARK.
73          *
74          * @return The public URI of the ARK
75          */
76         public String getPublicURI() {
77                 return publicURI;
78         }
79
80         /**
81          * Returns the private URI of the ARK.
82          *
83          * @return The private URI of the ARK
84          */
85         public String getPrivateURI() {
86                 return privateURI;
87         }
88
89         /**
90          * Returns the number of the ARK.
91          *
92          * @return The number of the ARK
93          */
94         public int getNumber() {
95                 return number;
96         }
97
98 }