1 package com.stateofflow.eclipse.metrics.calculators.cohesion;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.Set;
6
7 import org.eclipse.jdt.core.IJavaElement;
8
9 final class ElementToFieldSetMap {
10 private final Map<IJavaElement, FieldSet> map = new HashMap<IJavaElement, FieldSet>();
11
12 public void addField(final IJavaElement element, final String field) {
13 FieldSet fieldSet = map.get(element);
14 if (fieldSet == null) {
15 fieldSet = new FieldSet();
16 map.put(element, fieldSet);
17 }
18
19 fieldSet.add(field);
20 }
21
22 public boolean hasField(final IJavaElement element, final String field) {
23 return map.containsKey(element) && map.get(element).contains(field);
24 }
25
26 public void clear() {
27 map.clear();
28 }
29
30 public boolean isEmpty() {
31 return map.isEmpty();
32 }
33
34 public FieldSet get(final IJavaElement element) {
35 return map.get(element);
36 }
37
38 public Set<IJavaElement> keySet() {
39 return map.keySet();
40 }
41 }
42