net.ontopia.utils
Class CachedDecider<T>

java.lang.Object
  extended by net.ontopia.utils.CachedDecider<T>
All Implemented Interfaces:
CachedIF, DeciderIF<T>

public class CachedDecider<T>
extends java.lang.Object
implements DeciderIF<T>, CachedIF

INTERNAL: Decider that maintains a cache of decisions made on a set of objects. It works with any implementation of DeciderIF.

The cache is first checked to see if a decision has already been made. Otherwise a new decision is evaluated and the cache is updated.


Field Summary
protected  java.util.Map<T,java.lang.Boolean> cache
           
protected  DeciderIF<T> decider
           
 
Constructor Summary
CachedDecider(DeciderIF<T> decider)
           
 
Method Summary
 DeciderIF<T> getDecider()
          Gets the decider that being cached.
 boolean ok(T object)
          PUBLIC: Returns true if the object is accepted.
 void refresh()
          Refreshes the cache.
 void setDecider(DeciderIF<T> decider)
          Sets the decider that is to be cached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decider

protected DeciderIF<T> decider

cache

protected java.util.Map<T,java.lang.Boolean> cache
Constructor Detail

CachedDecider

public CachedDecider(DeciderIF<T> decider)
Method Detail

getDecider

public DeciderIF<T> getDecider()
Gets the decider that being cached.


setDecider

public void setDecider(DeciderIF<T> decider)
Sets the decider that is to be cached.


ok

public boolean ok(T object)
Description copied from interface: DeciderIF
PUBLIC: Returns true if the object is accepted.

Specified by:
ok in interface DeciderIF<T>

refresh

public void refresh()
Description copied from interface: CachedIF
Refreshes the cache.

Specified by:
refresh in interface CachedIF


Copyright © 2000-2012 Ontopia.