1 package com.stateofflow.eclipse.metrics.preferences;
2
3 import org.eclipse.jface.preference.IPreferenceStore;
4
5 import com.stateofflow.eclipse.metrics.configuration.MetricsConfiguration;
6 import com.stateofflow.eclipse.metrics.metric.MetricId;
7 import com.stateofflow.eclipse.metrics.metric.MetricPropertyKey;
8
9 public class PreferenceStoreMetricsConfiguration implements MetricsConfiguration {
10 private final IPreferenceStore preferenceStore;
11
12 public PreferenceStoreMetricsConfiguration(final IPreferenceStore preferenceStore) {
13 this.preferenceStore = preferenceStore;
14 }
15
16 public boolean isEnabled(final MetricId metricId) {
17 return getBoolean(metricId.createEnablementPropertyKey());
18 }
19
20 public int getUpperBound(final MetricId metricId) {
21 return getInt(metricId.createUpperBoundPropertyKey());
22 }
23
24 private int getInt(final MetricPropertyKey key) {
25 return preferenceStore.getInt(key.toString());
26 }
27
28 public boolean getBoolean(final MetricPropertyKey key) {
29 return preferenceStore.getBoolean(key.toString());
30 }
31 }
32