Changeset 1040 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatisticCache.java
- Timestamp:
- 01/16/13 17:51:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatisticCache.java
r1030 r1040 1 // Copyright 2012 Georg-August-Universität Göttingen, Germany 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 7 21 import com.google.common.cache.CacheBuilder; 8 22 23 /** 24 * <p> 25 * TODO comment 26 * </p> 27 * 28 * @author Alexander Deicke 29 */ 9 30 public class FilterStatisticCache { 10 31 11 32 private static final FilterStatisticCache instance = new FilterStatisticCache(); 12 33 13 34 @SuppressWarnings("rawtypes") 14 35 private Cache<TaskTreeNodeFilter, FilterStatistic> cache; 15 36 16 37 private FilterStatisticCache() { 17 38 this.cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(); 18 39 } 19 40 20 41 public static FilterStatisticCache instance() { 21 42 return instance; 22 43 } 23 44 24 45 @SuppressWarnings("rawtypes") 25 46 public void addFilterStatistic(TaskTreeNodeFilter nodeFilter, FilterStatistic filterStatistic) { 26 47 this.cache.put(nodeFilter, filterStatistic); 27 48 } 28 49 29 50 @SuppressWarnings("rawtypes") 30 51 public Optional<FilterStatistic> getFilterStatistic(TaskTreeNodeFilter nodeFilter) { 31 52 return Optional.fromNullable(this.cache.getIfPresent(nodeFilter)); 32 53 } 33 54 34 55 public void clear() { 35 56 this.cache.invalidateAll(); 36 57 } 37 58 38 59 }
Note: See TracChangeset
for help on using the changeset viewer.