]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterCollectorSupportImpl.java
isImmutable can NPE
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / ClusterCollectorSupportImpl.java
1 package fi.vtt.simantics.procore.internal;
2
3 import org.simantics.db.service.ClusterCollectorPolicy;
4 import org.simantics.db.service.ClusterCollectorPolicy.CollectorCluster;
5
6 class ClusterCollectorSupportImpl implements ClusterCollectorSupport {
7
8         private final ClusterTable clusterTable;
9
10         ClusterCollectorSupportImpl(ClusterTable clusterTable) {
11                 this.clusterTable = clusterTable;
12         }
13
14         @Override
15         public void setPolicy(ClusterCollectorPolicy policy) {
16                 clusterTable.setCollectorPolicy(policy);
17         }
18         
19         @Override
20         public int getCurrentSize() {
21                 return (int)this.clusterTable.getSizeInBytes();
22         }
23         
24         @Override
25         public long getClusterSize(CollectorCluster id) {
26             return clusterTable.getClusterByClusterId(id.getClusterId()).getCachedSize();
27         }
28         
29         @Override
30         public Iterable<CollectorCluster> getResidentClusters() {
31                 return clusterTable.importanceMap.values();
32         }
33
34         @Override
35         public void release(CollectorCluster id) {
36                 clusterTable.release(id);
37         }
38         
39 }