updated coding rules.
[utils] / support / general / src / main / java / org / wamblee / cache / CachedObject.java
index 58daf8c918ee3c53ff4ade7d31db0ee9d90fe279..f844c728e9b69d18c176ed3afc95133d223fe243 100644 (file)
@@ -51,17 +51,17 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
     /**
      * Cache to use.
      */
-    private Cache<KeyType, ValueType> _cache;
+    private Cache<KeyType, ValueType> cache;
 
     /**
      * Key of the object in the cache.
      */
-    private KeyType _objectKey;
+    private KeyType objectKey;
 
     /**
      * Computation used to obtain the object if it is not found in the cache.
      */
-    private Computation<KeyType, ValueType> _computation;
+    private Computation<KeyType, ValueType> computation;
 
     /**
      * Constructs the cached object.
@@ -76,9 +76,9 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
      */
     public CachedObject(Cache<KeyType, ValueType> aCache, KeyType aObjectKey,
             Computation<KeyType, ValueType> aComputation) {
-        _cache = aCache;
-        _objectKey = aObjectKey;
-        _computation = aComputation;
+        cache = aCache;
+        objectKey = aObjectKey;
+        computation = aComputation;
     }
 
     /**
@@ -88,7 +88,7 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
      * @return Object.
      */
     public ValueType get() {
-        ValueType object = (ValueType) _cache.get(_objectKey); // the used
+        ValueType object = (ValueType) cache.get(objectKey); // the used
                                                                 // cache is
                                                                 // thread safe.
         if (object == null) {
@@ -98,13 +98,13 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
             // be
             // recomputed.
             synchronized (this) {
-                object = (ValueType) _cache.get(_objectKey);
+                object = (ValueType) cache.get(objectKey);
                 if (object == null) {
                     // No other thread did a recomputation so we must do this
                     // now.
-                    LOGGER.debug("Refreshing cache for '" + _objectKey + "'");
-                    object = _computation.getObject(_objectKey);
-                    _cache.put(_objectKey, object);
+                    LOGGER.debug("Refreshing cache for '" + objectKey + "'");
+                    object = computation.getObject(objectKey);
+                    cache.put(objectKey, object);
                 }
             }
         }
@@ -117,7 +117,7 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
      * 
      */
     public void invalidate() {
-        _cache.remove(_objectKey);
+        cache.remove(objectKey);
     }
 
     /**
@@ -126,6 +126,6 @@ public class CachedObject<KeyType extends Serializable, ValueType extends Serial
      * @return Cache.
      */
     public Cache getCache() {
-        return _cache;
+        return cache;
     }
 }