diff --git a/checkstyle.xml b/checkstyle.xml index c6de354..285c8d1 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -335,7 +335,6 @@ - diff --git a/src/main/java/com/maxmind/db/CHMCache.java b/src/main/java/com/maxmind/db/CHMCache.java index 4989cdc..f9f6329 100644 --- a/src/main/java/com/maxmind/db/CHMCache.java +++ b/src/main/java/com/maxmind/db/CHMCache.java @@ -16,10 +16,20 @@ public class CHMCache implements NodeCache { private final ConcurrentHashMap cache; private boolean cacheFull = false; + /** + * Creates a new cache with the default capacity. + */ public CHMCache() { this(DEFAULT_CAPACITY); } + /** + * Creates a new cache with the specified capacity. + * + * @param capacity + * the maximum number of elements the cache can hold before + * starting to evict them + */ public CHMCache(int capacity) { this.capacity = capacity; this.cache = new ConcurrentHashMap<>(capacity); diff --git a/src/main/java/com/maxmind/db/InvalidNetworkException.java b/src/main/java/com/maxmind/db/InvalidNetworkException.java index 058cb32..b648f78 100644 --- a/src/main/java/com/maxmind/db/InvalidNetworkException.java +++ b/src/main/java/com/maxmind/db/InvalidNetworkException.java @@ -7,6 +7,10 @@ * IPv6 address in an IPv4-only database. */ public class InvalidNetworkException extends Exception { + /** + * @param ip + * the IP address that was used + */ public InvalidNetworkException(InetAddress ip) { super("you attempted to use an IPv6 network in an IPv4-only database: " + ip.toString()); } diff --git a/src/main/java/com/maxmind/db/NoCache.java b/src/main/java/com/maxmind/db/NoCache.java index 69e879c..f169e3b 100644 --- a/src/main/java/com/maxmind/db/NoCache.java +++ b/src/main/java/com/maxmind/db/NoCache.java @@ -16,7 +16,10 @@ private NoCache() { public DecodedValue get(CacheKey key, Loader loader) throws IOException { return loader.load(key); } - + + /** + * @return the singleton instance of the NoCache class + */ public static NoCache getInstance() { return INSTANCE; } diff --git a/src/main/java/com/maxmind/db/NodeCache.java b/src/main/java/com/maxmind/db/NodeCache.java index c66d532..5a2d817 100644 --- a/src/main/java/com/maxmind/db/NodeCache.java +++ b/src/main/java/com/maxmind/db/NodeCache.java @@ -10,9 +10,28 @@ public interface NodeCache { * A loader is used to load a value for a key that is not in the cache. */ interface Loader { + /** + * @param key + * the key to load + * @return the value for the key + * @throws IOException + * if there is an error loading the value + */ DecodedValue load(CacheKey key) throws IOException; } + /** + * This method returns the value for the key. If the key is not in the cache + * then the loader is called to load the value. + * + * @param key + * the key to look up + * @param loader + * the loader to use if the key is not in the cache + * @return the value for the key + * @throws IOException + * if there is an error loading the value + */ DecodedValue get(CacheKey key, Loader loader) throws IOException; }