5a25d8c5ddde6227088d0c50dffc4e693d4fa7d3
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiveDataSet / matrix / CategoricalDataHistogram.java
1 /**
2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10
11 import java.util.HashMap;
12 import java.util.Map;
13
14 import eu.etaxonomy.cdm.model.description.Feature;
15 import eu.etaxonomy.cdm.model.description.State;
16
17 /**
18 * @author pplitzner
19 * @since Jul 12, 2018
20 *
21 */
22 public class CategoricalDataHistogram {
23
24 private Feature feature;
25 private Map<State, Integer> stateCountMap;
26
27 public CategoricalDataHistogram(Feature feature) {
28 this.feature = feature;
29 this.stateCountMap = new HashMap<>();
30 feature.getSupportedCategoricalEnumerations()
31 .forEach(voc->voc.getTerms()
32 .forEach(state->stateCountMap.put(state, 0)));
33 }
34
35 public void addState(State state){
36 Integer integer = stateCountMap.get(state);
37 stateCountMap.put(state, integer+1);
38 }
39
40 public Map<State, Integer> getStateCountMap() {
41 return stateCountMap;
42 }
43
44 public Feature getFeature() {
45 return feature;
46 }
47 }