Skip to content

Commit

Permalink
Remove condition on the minimal amount of lines in method
Browse files Browse the repository at this point in the history
  • Loading branch information
shadromani committed Jan 22, 2024
1 parent 61a598d commit 5cca672
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 0 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@
</module>
<module name="MissingJavadocMethod">
<property name="scope" value="public"/>
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF,
COMPACT_CTOR_DEF"/>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/maxmind/db/CHMCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ public class CHMCache implements NodeCache {
private final ConcurrentHashMap<CacheKey, DecodedValue> 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);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/maxmind/db/InvalidNetworkException.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/maxmind/db/NoCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/maxmind/db/NodeCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

0 comments on commit 5cca672

Please sign in to comment.