Last change
on this file since 1030 was
1030,
checked in by adeicke, 11 years ago
|
Initial commit.
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1030] | 1 | package de.ugoe.cs.autoquest.usability.tasktree.filter;
|
---|
| 2 |
|
---|
| 3 | import java.util.concurrent.TimeUnit;
|
---|
| 4 |
|
---|
| 5 | import com.google.common.base.Optional;
|
---|
| 6 | import com.google.common.cache.Cache;
|
---|
| 7 | import com.google.common.cache.CacheBuilder;
|
---|
| 8 |
|
---|
| 9 | public class FilterStatisticCache {
|
---|
| 10 |
|
---|
| 11 | private static final FilterStatisticCache instance = new FilterStatisticCache();
|
---|
| 12 |
|
---|
| 13 | @SuppressWarnings("rawtypes")
|
---|
| 14 | private Cache<TaskTreeNodeFilter, FilterStatistic> cache;
|
---|
| 15 |
|
---|
| 16 | private FilterStatisticCache() {
|
---|
| 17 | this.cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build();
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public static FilterStatisticCache instance() {
|
---|
| 21 | return instance;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | @SuppressWarnings("rawtypes")
|
---|
| 25 | public void addFilterStatistic(TaskTreeNodeFilter nodeFilter, FilterStatistic filterStatistic) {
|
---|
| 26 | this.cache.put(nodeFilter, filterStatistic);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | @SuppressWarnings("rawtypes")
|
---|
| 30 | public Optional<FilterStatistic> getFilterStatistic(TaskTreeNodeFilter nodeFilter) {
|
---|
| 31 | return Optional.fromNullable(this.cache.getIfPresent(nodeFilter));
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public void clear() {
|
---|
| 35 | this.cache.invalidateAll();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.