From a4e63b7de06e4ca813c515fab41515d1747ff37c Mon Sep 17 00:00:00 2001
From: Robert von Burg
Date: Mon, 5 Sep 2016 11:58:46 +0200
Subject: [PATCH] [New] Added ObjectFilter.isEmpty()
---
.../utils/objectfilter/ObjectFilter.java | 21 +++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/objectfilter/ObjectFilter.java b/li.strolch.utils/src/main/java/li/strolch/utils/objectfilter/ObjectFilter.java
index b42c06139..d07035df9 100644
--- a/li.strolch.utils/src/main/java/li/strolch/utils/objectfilter/ObjectFilter.java
+++ b/li.strolch.utils/src/main/java/li/strolch/utils/objectfilter/ObjectFilter.java
@@ -88,8 +88,8 @@ public class ObjectFilter {
* Default constructor initializing the filter
*/
public ObjectFilter() {
- this.cache = new HashMap<>();
- this.keySet = new HashSet<>();
+ this.cache = new HashMap<>(1);
+ this.keySet = new HashSet<>(1);
}
/**
@@ -160,7 +160,7 @@ public class ObjectFilter {
default:
throw new IllegalStateException("Stale State exception: Unhandled state " + op); //$NON-NLS-1$
} // switch
- }// else of object not in cache
+ } // else of object not in cache
// register the key
this.keySet.add(key);
@@ -179,7 +179,8 @@ public class ObjectFilter {
}
/**
- * Register, under the given key, the update of the given object. *
+ * Register, under the given key, the update of the given object. *
+ *
*
*
* Action \ State in Cache |
@@ -241,14 +242,15 @@ public class ObjectFilter {
default:
throw new IllegalStateException("Stale State exception: Unhandled state " + op); //$NON-NLS-1$
} // switch
- }// else of object not in cache
+ } // else of object not in cache
// register the key
this.keySet.add(key);
}
/**
- * Register, under the given key, the removal of the given object. *
+ * Register, under the given key, the removal of the given object. *
+ *
*
*
* Action \ State in Cache |
@@ -679,6 +681,13 @@ public class ObjectFilter {
return this.cache.size();
}
+ /**
+ * @return true if the cache is empty, false otherwise
+ */
+ public boolean isEmpty() {
+ return this.cache.size() == 0;
+ }
+
/**
* @return get a unique transaction ID
*/