Skip to content

Commit cb678da

Browse files
committed
Merge branch 'christopherfrieler-feature/CLIENTS-1063-equals-implementations' into develop
2 parents 7c71419 + 08e6164 commit cb678da

8 files changed

Lines changed: 410 additions & 16 deletions

File tree

src/main/java/com/basho/riak/client/api/commands/buckets/FetchBucketProperties.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.basho.riak.client.core.operations.FetchBucketPropsOperation;
2121
import com.basho.riak.client.core.query.Namespace;
2222

23+
import java.util.Objects;
24+
2325
/**
2426
* Command used to fetch the properties of a bucket in Riak.
2527
* <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
@@ -30,9 +32,11 @@
3032
* FetchBucketProperties fbp = new FetchBucketProperties.Builder(ns).build();
3133
* FetchBucketPropsOperation.Response resp = client.execute(fbp);
3234
* BucketProperties props = resp.getBucketProperties();}</pre>
33-
* Note that this simply returns the core response {@link com.basho.riak.client.core.operations.FetchBucketPropsOperation.Response}
34-
*
35+
* Note that this simply returns the core response
36+
* {@link com.basho.riak.client.core.operations.FetchBucketPropsOperation.Response}
37+
* <p>
3538
* </p>
39+
*
3640
* @author Dave Rusek <drusek at basho dot com>
3741
* @since 2.0
3842
*/
@@ -51,6 +55,30 @@ protected FetchBucketPropsOperation buildCoreOperation()
5155
return new FetchBucketPropsOperation.Builder(namespace).build();
5256
}
5357

58+
@Override
59+
public boolean equals(Object other)
60+
{
61+
if (this == other)
62+
{
63+
return true;
64+
}
65+
66+
if (!(other instanceof FetchBucketProperties))
67+
{
68+
return false;
69+
}
70+
71+
FetchBucketProperties otherFetchBucketProperties = (FetchBucketProperties) other;
72+
73+
return Objects.equals(namespace, otherFetchBucketProperties.namespace);
74+
}
75+
76+
@Override
77+
public int hashCode()
78+
{
79+
return Objects.hash(namespace);
80+
}
81+
5482
/**
5583
* Builder used to construct a FetchBucketPoperties command.
5684
*/
@@ -60,6 +88,7 @@ public static class Builder
6088

6189
/**
6290
* Construct a Builder for a FetchBucketProperties command.
91+
*
6392
* @param namespace The namespace for the bucket.
6493
*/
6594
public Builder(Namespace namespace)
@@ -73,6 +102,7 @@ public Builder(Namespace namespace)
73102

74103
/**
75104
* Construct a new FetchBucketProperties command.
105+
*
76106
* @return a new FetchBucketProperties command.
77107
*/
78108
public FetchBucketProperties build()

src/main/java/com/basho/riak/client/api/commands/buckets/StoreBucketProperties.java

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@
2121
import com.basho.riak.client.core.query.Namespace;
2222
import com.basho.riak.client.core.query.functions.Function;
2323

24+
import java.util.Objects;
25+
2426
/**
2527
* Command used to store (modify) the properties of a bucket in Riak.
2628
* <p>
2729
* <pre class="prettyprint">
2830
* {@code
2931
* Namespace ns = new Namespace("my_type", "my_bucket");
3032
* StoreBucketProperties sbp =
31-
* new StoreBucketProperties.Builder(ns)
32-
* .withAllowMulti(true)
33-
* .build();
33+
* new StoreBucketProperties.Builder(ns)
34+
* .withAllowMulti(true)
35+
* .build();
3436
* client.execute(sbp);}</pre>
3537
* </p>
38+
*
3639
* @author Dave Rusek <drusek at basho dot com>
3740
* @since 2.0
3841
*/
@@ -94,8 +97,7 @@ public final class StoreBucketProperties extends AsIsRiakCommand<Void, Namespace
9497
@Override
9598
protected StoreBucketPropsOperation buildCoreOperation()
9699
{
97-
StoreBucketPropsOperation.Builder builder =
98-
new StoreBucketPropsOperation.Builder(namespace);
100+
StoreBucketPropsOperation.Builder builder = new StoreBucketPropsOperation.Builder(namespace);
99101

100102
if (allowMulti != null)
101103
{
@@ -215,6 +217,76 @@ protected StoreBucketPropsOperation buildCoreOperation()
215217
return builder.build();
216218
}
217219

220+
@Override
221+
public boolean equals(Object other)
222+
{
223+
if (this == other)
224+
{
225+
return true;
226+
}
227+
228+
if (!(other instanceof StoreBucketProperties))
229+
{
230+
return false;
231+
}
232+
233+
StoreBucketProperties otherStoreBucketProperties = (StoreBucketProperties) other;
234+
235+
return Objects.equals(namespace, otherStoreBucketProperties.namespace) &&
236+
Objects.equals(allowMulti, otherStoreBucketProperties.allowMulti) &&
237+
Objects.equals(backend, otherStoreBucketProperties.backend) &&
238+
Objects.equals(basicQuorum, otherStoreBucketProperties.basicQuorum) &&
239+
Objects.equals(bigVClock, otherStoreBucketProperties.bigVClock) &&
240+
Objects.equals(chashkeyFunction, otherStoreBucketProperties.chashkeyFunction) &&
241+
Objects.equals(lastWriteWins, otherStoreBucketProperties.lastWriteWins) &&
242+
Objects.equals(linkWalkFunction, otherStoreBucketProperties.linkWalkFunction) &&
243+
Objects.equals(rw, otherStoreBucketProperties.rw) &&
244+
Objects.equals(dw, otherStoreBucketProperties.dw) &&
245+
Objects.equals(w, otherStoreBucketProperties.w) &&
246+
Objects.equals(r, otherStoreBucketProperties.r) &&
247+
Objects.equals(pr, otherStoreBucketProperties.pr) &&
248+
Objects.equals(pw, otherStoreBucketProperties.pw) &&
249+
Objects.equals(notFoundOk, otherStoreBucketProperties.notFoundOk) &&
250+
Objects.equals(preCommitHook, otherStoreBucketProperties.preCommitHook) &&
251+
Objects.equals(postCommitHook, otherStoreBucketProperties.postCommitHook) &&
252+
Objects.equals(oldVClock, otherStoreBucketProperties.oldVClock) &&
253+
Objects.equals(youngVClock, otherStoreBucketProperties.youngVClock) &&
254+
Objects.equals(smallVClock, otherStoreBucketProperties.smallVClock) &&
255+
Objects.equals(nval, otherStoreBucketProperties.nval) &&
256+
Objects.equals(legacySearch, otherStoreBucketProperties.legacySearch) &&
257+
Objects.equals(searchIndex, otherStoreBucketProperties.searchIndex) &&
258+
Objects.equals(hllPrecision, otherStoreBucketProperties.hllPrecision);
259+
}
260+
261+
@Override
262+
public int hashCode()
263+
{
264+
return Objects.hash(namespace,
265+
allowMulti,
266+
backend,
267+
basicQuorum,
268+
bigVClock,
269+
chashkeyFunction,
270+
lastWriteWins,
271+
linkWalkFunction,
272+
rw,
273+
dw,
274+
w,
275+
r,
276+
pr,
277+
pw,
278+
notFoundOk,
279+
preCommitHook,
280+
postCommitHook,
281+
oldVClock,
282+
youngVClock,
283+
smallVClock,
284+
nval,
285+
legacySearch,
286+
searchIndex,
287+
hllPrecision);
288+
}
289+
218290
public static class Builder
219291
{
220292
private final Namespace namespace;
@@ -282,7 +354,7 @@ public Builder withBackend(String backend)
282354

283355
/**
284356
* Set the basic_quorum value.
285-
*
357+
* <p>
286358
* The parameter controls whether a read request should return early in
287359
* some fail cases. E.g. If a quorum of nodes has already returned
288360
* notfound/error, don't wait around for the rest.
@@ -301,7 +373,9 @@ public Builder withBasicQuorum(boolean use)
301373
*
302374
* @param bigVClock a long representing a epoch time value.
303375
* @return a reference to this object.
304-
* @see <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector Clock Pruning</a>
376+
* @see
377+
* <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector
378+
* Clock Pruning</a>
305379
*/
306380
public Builder withBigVClock(Long bigVClock)
307381
{
@@ -475,7 +549,9 @@ public Builder withPostcommitHook(Function hook)
475549
*
476550
* @param oldVClock an long representing a epoch time value.
477551
* @return a reference to this object.
478-
* @see <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector Clock Pruning</a>
552+
* @see
553+
* <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector
554+
* Clock Pruning</a>
479555
*/
480556
public Builder withOldVClock(Long oldVClock)
481557
{
@@ -488,7 +564,9 @@ public Builder withOldVClock(Long oldVClock)
488564
*
489565
* @param youngVClock a long representing a epoch time value.
490566
* @return a reference to this object.
491-
* @see <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector Clock Pruning</a>
567+
* @see
568+
* <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector
569+
* Clock Pruning</a>
492570
*/
493571
public Builder withYoungVClock(Long youngVClock)
494572
{
@@ -501,7 +579,9 @@ public Builder withYoungVClock(Long youngVClock)
501579
*
502580
* @param smallVClock a long representing a epoch time value.
503581
* @return a reference to this object.
504-
* @see <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector Clock Pruning</a>
582+
* @see
583+
* <a href="http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/#Vector-Clock-Pruning">Vector
584+
* Clock Pruning</a>
505585
*/
506586
public Builder withSmallVClock(Long smallVClock)
507587
{
@@ -528,11 +608,11 @@ public Builder withNVal(int nVal)
528608
/**
529609
* Enable Legacy Riak Search. Setting this to true causes the search
530610
* pre-commit hook to be added.
531-
*
611+
* <p>
532612
* <b>Note this is only for legacy Riak (&lt; v2.0) Search support.</b>
533613
*
534614
* @param enable add/remove (true/false) the pre-commit hook for Legacy
535-
* Riak Search.
615+
* Riak Search.
536616
* @return a reference to this object.
537617
*/
538618
public Builder withLegacyRiakSearchEnabled(boolean enable)

src/main/java/com/basho/riak/client/api/commands/search/StoreIndex.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.basho.riak.client.core.operations.YzPutIndexOperation;
55
import com.basho.riak.client.core.query.search.YokozunaIndex;
66

7+
import java.util.Objects;
8+
79
/**
810
* Command used to store a search index in Riak.
911
* <p>
@@ -36,6 +38,31 @@ protected YzPutIndexOperation buildCoreOperation()
3638
return opBuilder.build();
3739
}
3840

41+
@Override
42+
public boolean equals(Object other)
43+
{
44+
if (this == other)
45+
{
46+
return true;
47+
}
48+
49+
if (!(other instanceof StoreIndex))
50+
{
51+
return false;
52+
}
53+
54+
Builder otherStoreIndex = ((StoreIndex) other).cmdBuilder;
55+
56+
return Objects.equals(cmdBuilder.index, otherStoreIndex.index) &&
57+
Objects.equals(cmdBuilder.timeout, otherStoreIndex.timeout);
58+
}
59+
60+
@Override
61+
public int hashCode()
62+
{
63+
return Objects.hash(cmdBuilder.index, cmdBuilder.timeout);
64+
}
65+
3966
/**
4067
* Builder for a StoreIndex command.
4168
*/
@@ -60,6 +87,7 @@ public Builder(YokozunaIndex index)
6087
* By default, riak has a 45s timeout for Yokozuna index creation.
6188
* Setting this value will override that default for this operation.
6289
* </p>
90+
*
6391
* @param timeout the timeout in milliseconds to be sent to riak.
6492
* @return a reference to this object.
6593
*/

src/main/java/com/basho/riak/client/core/query/search/YokozunaIndex.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.basho.riak.client.core.query.search;
1717

18+
import java.util.Objects;
19+
1820
/**
1921
* Represents a Yokozuna Index.
2022
*
@@ -28,7 +30,7 @@ public class YokozunaIndex
2830

2931
/**
3032
* Constructs a Yokozuna index without naming the schema.
31-
*
33+
* <p>
3234
* Due to an implementation detail on the Riak side, the index name is restricted
3335
* to US-ASCII characters. The supplied String is converted to bytes
3436
* using the UTF-8 Charset.
@@ -46,7 +48,7 @@ public YokozunaIndex(String name)
4648
* to US-ASCII characters. The supplied String is converted to bytes
4749
* using the UTF-8 Charset.
4850
*
49-
* @param name The name of the index.
51+
* @param name The name of the index.
5052
* @param schema The name of a schema
5153
*/
5254
public YokozunaIndex(String name, String schema)
@@ -89,6 +91,7 @@ public String getName()
8991

9092
/**
9193
* Returns the schema name for this index.
94+
*
9295
* @return The schema name.
9396
*/
9497
public String getSchema()
@@ -115,4 +118,30 @@ public Integer getNVal()
115118
{
116119
return nVal;
117120
}
121+
122+
@Override
123+
public boolean equals(Object other)
124+
{
125+
if (this == other)
126+
{
127+
return true;
128+
}
129+
130+
if (!(other instanceof YokozunaIndex))
131+
{
132+
return false;
133+
}
134+
135+
YokozunaIndex otherYokozunaIndex = (YokozunaIndex) other;
136+
137+
return Objects.equals(name, otherYokozunaIndex.name) &&
138+
Objects.equals(schema, otherYokozunaIndex.schema) &&
139+
Objects.equals(nVal, otherYokozunaIndex.nVal);
140+
}
141+
142+
@Override
143+
public int hashCode()
144+
{
145+
return Objects.hash(name, schema, nVal);
146+
}
118147
}

0 commit comments

Comments
 (0)