File tree Expand file tree Collapse file tree
main/java/com/basho/riak/client/core/query/search
test/java/com/basho/riak/client/core/query/search Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 */
1616package com .basho .riak .client .core .query .search ;
1717
18+ import java .util .Objects ;
19+
1820/**
1921 * Represents a Yokozuna Index.
2022 *
@@ -115,4 +117,23 @@ public Integer getNVal()
115117 {
116118 return nVal ;
117119 }
120+
121+ @ Override
122+ public boolean equals (Object other ) {
123+ if (this == other ) {
124+ return true ;
125+ }
126+ if (!(other instanceof YokozunaIndex )) {
127+ return false ;
128+ }
129+ YokozunaIndex otherYokozunaIndex = (YokozunaIndex ) other ;
130+ return Objects .equals (name , otherYokozunaIndex .name ) &&
131+ Objects .equals (schema , otherYokozunaIndex .schema ) &&
132+ Objects .equals (nVal , otherYokozunaIndex .nVal );
133+ }
134+
135+ @ Override
136+ public int hashCode () {
137+ return Objects .hash (name , schema , nVal );
138+ }
118139}
Original file line number Diff line number Diff line change 1+ package com .basho .riak .client .core .query .search ;
2+
3+ import org .junit .Test ;
4+ import static org .hamcrest .CoreMatchers .equalTo ;
5+ import static org .hamcrest .CoreMatchers .is ;
6+ import static org .hamcrest .CoreMatchers .not ;
7+ import static org .hamcrest .MatcherAssert .assertThat ;
8+
9+ public class YokozunaIndexTest {
10+ @ Test
11+ public void equalsReturnsTrueForEqualYokozunaIndices () {
12+ YokozunaIndex yokozunaIndex1 = new YokozunaIndex ("name" , "schema" ).withNVal (3 );
13+ YokozunaIndex yokozunaIndex2 = new YokozunaIndex ("name" , "schema" ).withNVal (3 );
14+
15+ assertThat (yokozunaIndex1 , is (equalTo (yokozunaIndex2 )));
16+ assertThat (yokozunaIndex2 , is (equalTo (yokozunaIndex1 )));
17+ }
18+
19+ @ Test
20+ public void equalsReturnsFalseForDifferentYokozunaIndices () {
21+ YokozunaIndex yokozunaIndex1 = new YokozunaIndex ("name1" , "schema1" ).withNVal (3 );
22+ YokozunaIndex yokozunaIndex2 = new YokozunaIndex ("name2" , "schema2" ).withNVal (5 );
23+
24+ assertThat (yokozunaIndex1 , is (not (equalTo (yokozunaIndex2 ))));
25+ assertThat (yokozunaIndex2 , is (not (equalTo (yokozunaIndex1 ))));
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments