DATACASS-250 - Polish.

Resolves gh-107
This commit is contained in:
John Blum
2017-06-11 23:04:22 -07:00
parent 8d64401aa8
commit b72ad3dc3f
6 changed files with 31 additions and 31 deletions

View File

@@ -257,8 +257,8 @@ public interface AsyncCassandraOperations {
*
* @param entity The entity to update, must not be {@literal null}.
* @param options may be {@literal null}.
* @return the updated entityor a {@literal null} inside of {@link ListenableFuture} if the {@code UPDATE} operation
* was not applied.
* @return the updated entity or a {@literal null} inside of {@link ListenableFuture}
* if the {@code UPDATE} operation was not applied.
* @throws DataAccessException if there is any problem executing the query.
*/
<T> ListenableFuture<T> update(T entity, UpdateOptions options) throws DataAccessException;

View File

@@ -47,7 +47,7 @@ public class InsertOptions extends WriteOptions {
* @return {@literal true} to apply {@code IF NOT EXISTS} to {@code INSERT} operations.
*/
public boolean isIfNotExists() {
return ifNotExists;
return this.ifNotExists;
}
/**
@@ -164,7 +164,7 @@ public class InsertOptions extends WriteOptions {
InsertOptions insertOptions = applyOptions(new InsertOptions());
insertOptions.ifNotExists = ifNotExists;
insertOptions.ifNotExists = this.ifNotExists;
return insertOptions;
}

View File

@@ -47,7 +47,7 @@ public class UpdateOptions extends WriteOptions {
* @return {@literal true} to apply {@code IF EXISTS} to {@code UPDATE} operations.
*/
public boolean isIfExists() {
return ifExists;
return this.ifExists;
}
/**
@@ -164,7 +164,7 @@ public class UpdateOptions extends WriteOptions {
UpdateOptions insertOptions = applyOptions(new UpdateOptions());
insertOptions.ifExists = ifExists;
insertOptions.ifExists = this.ifExists;
return insertOptions;
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.cql.core;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.springframework.util.Assert;
@@ -84,7 +85,7 @@ public class QueryOptions {
* @since 1.5
*/
protected ConsistencyLevel getConsistencyLevel() {
return consistencyLevel;
return this.consistencyLevel;
}
/**
@@ -104,7 +105,7 @@ public class QueryOptions {
* @since 1.5
*/
protected RetryPolicy getRetryPolicy() {
return retryPolicy;
return this.retryPolicy;
}
/**
@@ -123,6 +124,7 @@ public class QueryOptions {
public void setFetchSize(int fetchSize) {
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater than equal to zero");
this.fetchSize = fetchSize;
}
@@ -147,6 +149,7 @@ public class QueryOptions {
public void setReadTimeout(long readTimeout) {
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater than equal to zero");
this.readTimeout = readTimeout;
}
@@ -155,7 +158,7 @@ public class QueryOptions {
* @since 1.5
*/
protected Long getReadTimeout() {
return readTimeout;
return this.readTimeout;
}
/**
@@ -172,7 +175,7 @@ public class QueryOptions {
* @return whether to enable tracing. May be {@literal null} if not set.
*/
protected Boolean getTracing() {
return tracing;
return this.tracing;
}
/**
@@ -206,6 +209,7 @@ public class QueryOptions {
Assert.notNull(consistencyLevel, "ConsistencyLevel must not be null");
this.consistencyLevel = consistencyLevel;
return this;
}
@@ -221,6 +225,7 @@ public class QueryOptions {
Assert.notNull(retryPolicy, "RetryPolicy must not be null");
this.retryPolicy = retryPolicy;
return this;
}
@@ -239,9 +244,10 @@ public class QueryOptions {
*/
public QueryOptionsBuilder fetchSize(int fetchSize) {
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater or equal to zero");
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater than equal to zero");
this.fetchSize = fetchSize;
return this;
}
@@ -256,7 +262,7 @@ public class QueryOptions {
*/
public QueryOptionsBuilder readTimeout(long readTimeout) {
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater or equal to zero");
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater than equal to zero");
this.readTimeout = readTimeout;
@@ -275,7 +281,7 @@ public class QueryOptions {
*/
public QueryOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) {
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater or equal to zero");
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater than equal to zero");
Assert.notNull(timeUnit, "TimeUnit must not be null");
this.readTimeout = timeUnit.toMillis(readTimeout);
@@ -292,6 +298,7 @@ public class QueryOptions {
public QueryOptionsBuilder tracing(boolean tracing) {
this.tracing = tracing;
return this;
}
@@ -320,17 +327,9 @@ public class QueryOptions {
queryOptions.setConsistencyLevel(consistencyLevel);
queryOptions.setRetryPolicy(retryPolicy);
if (fetchSize != null) {
queryOptions.setFetchSize(fetchSize);
}
if (readTimeout != null) {
queryOptions.setReadTimeout(readTimeout);
}
if (tracing != null) {
queryOptions.setTracing(tracing);
}
Optional.ofNullable(this.fetchSize).ifPresent(queryOptions::setFetchSize);
Optional.ofNullable(this.readTimeout).ifPresent(queryOptions::setReadTimeout);
Optional.ofNullable(this.tracing).ifPresent(queryOptions::setTracing);
return options;
}

View File

@@ -73,7 +73,7 @@ public class WriteOptions extends QueryOptions {
* @return the time to live, if set.
*/
public Integer getTtl() {
return ttl;
return this.ttl;
}
/**
@@ -184,7 +184,8 @@ public class WriteOptions extends QueryOptions {
protected <T> T applyOptions(T queryOptions) {
WriteOptions writeOptions = (WriteOptions) queryOptions;
writeOptions.setTtl(ttl);
writeOptions.setTtl(this.ttl);
return super.applyOptions(queryOptions);
}

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.data.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
@@ -27,14 +27,14 @@ import org.junit.Test;
public class UpdateOptionsUnitTests {
@Test // DATACASS-250
public void shouldConfigureInsertOptions() {
public void shouldConfigureUpdateOptions() {
UpdateOptions insertOptions = UpdateOptions.builder() //
UpdateOptions updateOptions = UpdateOptions.builder() //
.ttl(10) //
.withIfExists() //
.build();
assertThat(insertOptions.getTtl()).isEqualTo(10);
assertThat(insertOptions.isIfExists()).isTrue();
assertThat(updateOptions.getTtl()).isEqualTo(10);
assertThat(updateOptions.isIfExists()).isTrue();
}
}