View Javadoc

1   package org.lcsim.conditions;
2   
3   /**
4    * @version $Id: CachedConditionsImplementation.java,v 1.1.1.1 2010/01/25
5    *          22:23:07 jeremy Exp $
6    * @author tonyj
7    */
8   class CachedConditionsImplementation<T> extends ConditionsImplementation implements CachedConditions<T>, ConditionsListener {
9       private ConditionsConverter<T> conv;
10      private T data;
11  
12      CachedConditionsImplementation(ConditionsManagerImplementation manager, String name, ConditionsConverter<T> conv) {
13          super(manager, name);
14          this.conv = conv;
15          manager.addConditionsListener(this);
16      }
17  
18      public T getCachedData() {
19          if (data == null)
20              data = conv.getData(getManager(), getName());
21          return data;
22      }
23  
24      public void conditionsChanged(ConditionsEvent conditionsEvent) {
25          data = null;
26      }
27  }