Override toString() to output sensible information.
[arachne.git] / src / net / pterodactylus / arachne / core / Site.java
1 /*
2  * © 2009 David ‘Bombe’ Roden
3  */
4 package net.pterodactylus.arachne.core;
5
6 import de.ina.util.validation.Validation;
7
8 /**
9  * Container for a freenet site. A freenet site consists of the routing and
10  * decryption keys and the basename, without the edition.
11  *
12  * @author David ‘Bombe’ Roden <bombe@pterodactylus.net>
13  */
14 public class Site {
15
16         /** The key of the site. */
17         private final String key;
18
19         /** The basename of the site. */
20         private final String basename;
21
22         /**
23          * Creates a new site with the given key and basename.
24          *
25          * @param key
26          *            The key of the site
27          * @param basename
28          *            The basename of the site
29          */
30         public Site(String key, String basename) {
31                 Validation.begin().isNotNull("key", (Object) key).isNotNull("basename", (Object) basename).check();
32                 this.key = key;
33                 this.basename = basename;
34         }
35
36         /**
37          * The routing and decryption keys of the site.
38          *
39          * @return The site’s routing and decryption keys
40          */
41         public String getKey() {
42                 return key;
43         }
44
45         /**
46          * Returns the basename of the site, without the edition number.
47          *
48          * @return The site’s basename
49          */
50         public String getBasename() {
51                 return basename;
52         }
53
54         //
55         // OBJECT METHODS
56         //
57
58         /**
59          * {@inheritdoc}
60          *
61          * @see java.lang.Object#toString()
62          */
63         @Override
64         public String toString() {
65                 return getClass().getName() + "[key=" + key + ",basename=" + basename + "]";
66         }
67
68 }