2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
;
11 import java
.util
.HashSet
;
13 import java
.util
.UUID
;
15 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
16 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
17 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
20 * Wrapper class for comparing description elements
25 public class DescriptionElementCompareWrapper
{
27 private DescriptionElementBase element
;
28 private Set
<UUID
> stateUuids
= new HashSet
<>();
29 private Float min
= null;
30 private Float max
= null;
32 public DescriptionElementCompareWrapper(DescriptionElementBase element
) {
33 this.element
= element
;
34 if(element
.isInstanceOf(CategoricalData
.class)){
35 CategoricalData elementData
= (CategoricalData
)element
;
36 elementData
.getStatesOnly().forEach(state
->stateUuids
.add(state
.getUuid()));
38 else if(element
.isInstanceOf(QuantitativeData
.class)){
39 QuantitativeData elementData
= (QuantitativeData
)element
;
40 min
= elementData
.getMin();
41 max
= elementData
.getMax();
45 public DescriptionElementBase
unwrap() {
53 public int hashCode() {
56 result
= prime
* result
+ ((max
== null) ?
0 : max
.hashCode());
57 result
= prime
* result
+ ((min
== null) ?
0 : min
.hashCode());
58 result
= prime
* result
+ ((stateUuids
== null) ?
0 : stateUuids
.hashCode());
66 public boolean equals(Object obj
) {
73 if (getClass() != obj
.getClass()) {
76 DescriptionElementCompareWrapper other
= (DescriptionElementCompareWrapper
) obj
;
78 if (other
.max
!= null) {
81 } else if (!max
.equals(other
.max
)) {
85 if (other
.min
!= null) {
88 } else if (!min
.equals(other
.min
)) {
91 if (stateUuids
== null) {
92 if (other
.stateUuids
!= null) {
95 } else if (!stateUuids
.equals(other
.stateUuids
)) {