diff options
author | 2015-11-22 10:02:05 -0800 | |
---|---|---|
committer | 2015-11-22 10:02:05 -0800 | |
commit | 77ce3be7567bd01c66d8ee88a93b485666723501 (patch) | |
tree | 283e7f39a501750bbd705fbb91645b20198900f1 /framework/src/onos/utils/misc | |
parent | 00e6500d0813dcbccaaa741ef38cc1eae6d11e07 (diff) |
Removed patch path since changes have been merged upstream to a different path. Updated README with directions.
Change-Id: Ie419abd2d3d3ef7315de9f607dcd757a78190995
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/utils/misc')
-rw-r--r-- | framework/src/onos/utils/misc/src/main/java/org/onlab/util/DefaultHashMap.java | 4 | ||||
-rw-r--r-- | framework/src/onos/utils/misc/src/main/java/org/onlab/util/Tools.java | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/DefaultHashMap.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/DefaultHashMap.java index f9d878ab..d6ddbd56 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/DefaultHashMap.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/DefaultHashMap.java @@ -21,10 +21,10 @@ import java.util.HashMap; /** * HashMap that returns a default value for unmapped keys. */ -public class DefaultHashMap<K, V> extends HashMap<K, V> { +public final class DefaultHashMap<K, V> extends HashMap<K, V> { /** Default value to return when no key binding exists. */ - protected V defaultValue; + protected final V defaultValue; /** * Constructs an empty map with the given default value. diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Tools.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Tools.java index 1b788145..ffefbfd4 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Tools.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Tools.java @@ -40,6 +40,7 @@ import java.util.Collection; import java.util.Dictionary; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -144,6 +145,23 @@ public abstract class Tools { } /** + * Returns the specified set if the set is not null and not empty; + * otherwise throws a not found exception. + * + * @param item set to check + * @param message not found message + * @param <T> Set item type + * @return item if not null and not empty + * @throws org.onlab.util.ItemNotFoundException if set is null or empty + */ + public static <T> Set<T> emptyIsNotFound(Set<T> item, String message) { + if (item == null || item.isEmpty()) { + throw new ItemNotFoundException(message); + } + return item; + } + + /** * Returns the specified item if that item is not null; otherwise throws * bad argument exception. * |