hchar 2005/02/01 03:46:08
Modified: sandbox/yajcache/src/org/apache/jcs/yajcache/core
CacheType.java
Log:
add isAssignableFrom
Revision Changes Path
1.5 +32 -0
jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/core/CacheType.java
Index: CacheType.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/core/CacheType.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CacheType.java 1 Feb 2005 10:32:39 -0000 1.4
+++ CacheType.java 1 Feb 2005 11:46:08 -0000 1.5
@@ -34,6 +34,7 @@
SOFT_REFERENCE_FILE,
SOFT_REFERENCE_FILE_SAFE;
+ /** Instantiates and returns a new instance of cache of the current
type. */
<V> ICache<V> createCache(String name, @NonNullable Class<V> valueType)
{
switch(this) {
@@ -48,6 +49,7 @@
}
throw new AssertionError(this);
}
+ /** Instantiates and returns a new instance of safe cache of the current
type. */
<V> ICacheSafe<V> createSafeCache(String name, @NonNullable Class<V>
valueType)
{
switch(this) {
@@ -58,4 +60,34 @@
}
throw new UnsupportedOperationException("");
}
+ /**
+ * Returns true if cache of the given cache type can be used as
+ * cache of the current cache type;
+ * false otherwise.
+ */
+ public boolean isAsssignableFrom(CacheType from) {
+ switch(this) {
+ case SOFT_REFERENCE:
+ return true;
+ case SOFT_REFERENCE_SAFE:
+ switch(from) {
+ case SOFT_REFERENCE_SAFE:
+ case SOFT_REFERENCE_FILE_SAFE:
+ return true;
+ default:
+ return false;
+ }
+ case SOFT_REFERENCE_FILE:
+ switch(from) {
+ case SOFT_REFERENCE_FILE:
+ case SOFT_REFERENCE_FILE_SAFE:
+ return true;
+ default:
+ return false;
+ }
+ case SOFT_REFERENCE_FILE_SAFE:
+ return from == SOFT_REFERENCE_FILE_SAFE;
+ }
+ throw new AssertionError(this);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]