X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fcache%2FCachedObject.java;h=3d200b5ad38d1ba9818c9d4c3d53ebb11f85eaf0;hb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;hp=58daf8c918ee3c53ff4ade7d31db0ee9d90fe279;hpb=32a62ca2c752e33a7873ac868a7a1f289caedcd4;p=utils diff --git a/support/general/src/main/java/org/wamblee/cache/CachedObject.java b/support/general/src/main/java/org/wamblee/cache/CachedObject.java index 58daf8c9..3d200b5a 100644 --- a/support/general/src/main/java/org/wamblee/cache/CachedObject.java +++ b/support/general/src/main/java/org/wamblee/cache/CachedObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,56 +12,38 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - + */ package org.wamblee.cache; -import java.io.Serializable; - import org.apache.log4j.Logger; +import java.io.Serializable; + /** * Represents a cached object. The object is either retrieved from the cache if * the cache has it, or a call back is invoked to get the object (and put it in * the cache). - * + * * @author Erik Brakkee + * */ public class CachedObject { - private static final Logger LOGGER = Logger.getLogger(CachedObject.class); - /** - * Callback invoked to compute an object if it was not found in the cache. - * - * @param - * Type of the object - */ - public static interface Computation { - /** - * Gets the object. Called when the object is not in the cache. - * - * @param aObjectKey - * Id of the object in the cache. - * @return Object, must be non-null. - */ - Value getObject(Key aObjectKey); - } - /** * Cache to use. */ - private Cache _cache; + private Cache 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 _computation; + private Computation computation; /** * Constructs the cached object. @@ -75,10 +57,10 @@ public class CachedObject aCache, KeyType aObjectKey, - Computation aComputation) { - _cache = aCache; - _objectKey = aObjectKey; - _computation = aComputation; + Computation aComputation) { + cache = aCache; + objectKey = aObjectKey; + computation = aComputation; } /** @@ -88,9 +70,10 @@ public class CachedObject + * Type of the object + */ + public static interface Computation { + /** + * Gets the object. Called when the object is not in the cache. + * + * @param aObjectKey + * Id of the object in the cache. + * + * @return Object, must be non-null. + */ + Value getObject(Key aObjectKey); } }