Skip to content

Commit ff8ced5

Browse files
committed
add equals and hashcode to AFM ExpressionFilter
1 parent cfcfbd0 commit ff8ced5

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/main/java/com/gooddata/executeafm/afm/ExpressionFilter.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved.
2+
* Copyright (C) 2007-2018, GoodData(R) Corporation. All rights reserved.
33
* This source code is licensed under the BSD-style license found in the
44
* LICENSE.txt file in the root directory of this source tree.
55
*/
@@ -10,11 +10,13 @@
1010
import com.fasterxml.jackson.annotation.JsonRootName;
1111
import com.gooddata.util.GoodDataToStringBuilder;
1212

13+
import java.util.Objects;
14+
1315
/**
1416
* To be deprecated filter using plain expression
1517
*/
1618
@JsonRootName("expression")
17-
public class ExpressionFilter implements CompatibilityFilter {
19+
public final class ExpressionFilter implements CompatibilityFilter {
1820
static final String NAME = "expression";
1921
private final String value;
2022

@@ -27,12 +29,27 @@ public ExpressionFilter(@JsonProperty("value") final String value) {
2729
this.value = value;
2830
}
2931

30-
public String getValue() {
32+
public String getValue() {
3133
return value;
3234
}
3335

3436
@Override
3537
public String toString() {
3638
return GoodDataToStringBuilder.defaultToString(this);
3739
}
40+
41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o)
44+
return true;
45+
if (!(o instanceof ExpressionFilter))
46+
return false;
47+
ExpressionFilter that = (ExpressionFilter) o;
48+
return Objects.equals(value, that.value);
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
return Objects.hash(value);
54+
}
3855
}

src/test/groovy/com/gooddata/executeafm/afm/ExpressionFilterTest.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/*
2-
* Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved.
2+
* Copyright (C) 2007-2018, GoodData(R) Corporation. All rights reserved.
33
* This source code is licensed under the BSD-style license found in the
44
* LICENSE.txt file in the root directory of this source tree.
55
*/
66
package com.gooddata.executeafm.afm
77

8+
import nl.jqno.equalsverifier.EqualsVerifier
89
import spock.lang.Specification
910

1011
import static com.gooddata.util.ResourceUtils.readObjectFromResource
@@ -29,4 +30,9 @@ class ExpressionFilterTest extends Specification {
2930
filter.value == 'some expression'
3031
filter.toString()
3132
}
33+
34+
def "should verify equals"() {
35+
expect:
36+
EqualsVerifier.forClass(ExpressionFilter).verify()
37+
}
3238
}

0 commit comments

Comments
 (0)