Skip to content

Commit eed7758

Browse files
warnings fix (#20)
- warnings fix - Fix error-prone and Intellij compiler warnings - Fixed spelling errors - Fixed @OverRide errors - Make method signature uniform across interface and implementation - Simplify code suggested by Intellij - Make things final where possible - Fix indentation - Removed unused imports, use equalsIgnoreCase, added null check on tableName.
1 parent d936b9f commit eed7758

31 files changed

+190
-178
lines changed

src/main/java/com/oracle/nosql/spring/data/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Constants {
1616
public static final String DEFAULT_REPOSITORY_IMPLEMENT_POSTFIX = "Impl";
1717
public static final String NOSQL_XML_TEMPLATE_REF = "nosql-template-ref";
1818
public static final int DEFAULT_TABLE_REQ_TIMEOUT_MS = 60000;
19-
public static final int DEFAULT_TABLE_REQ_POLL_INTEVEL_MS = 500;
19+
public static final int DEFAULT_TABLE_RED_POLL_INTERVAL_MS = 500;
2020
public static final int DEFAULT_QUERY_CACHE_CAPACITY = 1000;
2121
public static final int DEFAULT_QUERY_CACHE_LIFETIME_MS = 1000 * 60 * 10; // 10min
2222
public static final int DEFAULT_TIMESTAMP_PRECISION = 3;

src/main/java/com/oracle/nosql/spring/data/NosqlDbFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public int getTableReqTimeout() {
145145

146146
/**
147147
* Returns the table request poll interval in milliseconds. By default, this
148-
* is set to {@link Constants#DEFAULT_TABLE_REQ_POLL_INTEVEL_MS}
148+
* is set to {@link Constants#DEFAULT_TABLE_RED_POLL_INTERVAL_MS}
149149
*/
150150
public int getTableReqPollInterval() {
151151
return config.getTableReqPollInterval();

src/main/java/com/oracle/nosql/spring/data/config/NosqlDbConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
public class NosqlDbConfig {
2525

26-
private NoSQLHandleConfig nosqlHandleConfig;
26+
private final NoSQLHandleConfig nosqlHandleConfig;
2727
private int queryCacheCapacity = Constants.DEFAULT_QUERY_CACHE_CAPACITY;
2828
private int queryCacheLifetime = Constants.DEFAULT_QUERY_CACHE_LIFETIME_MS;
2929
private int tableReqTimeout = Constants.DEFAULT_TABLE_REQ_TIMEOUT_MS;
30-
private int tableReqPollInterval = Constants.DEFAULT_TABLE_REQ_POLL_INTEVEL_MS;
30+
private int tableReqPollInterval = Constants.DEFAULT_TABLE_RED_POLL_INTERVAL_MS;
3131
private int timestampPrecision = Constants.DEFAULT_TIMESTAMP_PRECISION;
3232
private int defaultStorageGB = 25;
3333
private NosqlCapacityMode defaultCapacityMode = NosqlCapacityMode.PROVISIONED;
@@ -167,7 +167,7 @@ public int getQueryCacheLifetime() {
167167
* only ever removed because the cache has reached capacity.
168168
*/
169169
NosqlDbConfig setQueryCacheLifetime(int lifetime) {
170-
queryCacheCapacity = lifetime;
170+
queryCacheLifetime = lifetime;
171171
return this;
172172
}
173173

@@ -187,14 +187,14 @@ public NosqlDbConfig setTableReqTimeout(int tableReqTimeout) {
187187
}
188188

189189
/** Returns the table request poll interval in milliseconds. By default this
190-
* is set to {@link Constants#DEFAULT_TABLE_REQ_POLL_INTEVEL_MS}
190+
* is set to {@link Constants#DEFAULT_TABLE_RED_POLL_INTERVAL_MS}
191191
*/
192192
public int getTableReqPollInterval() {
193193
return tableReqPollInterval;
194194
}
195195

196196
/** Sets the table request poll interval in milliseconds. By default
197-
* this is set to {@link Constants#DEFAULT_TABLE_REQ_POLL_INTEVEL_MS}
197+
* this is set to {@link Constants#DEFAULT_TABLE_RED_POLL_INTERVAL_MS}
198198
*/
199199
public NosqlDbConfig setTableReqPollInterval(int pollInterval) {
200200
this.tableReqPollInterval = pollInterval;

src/main/java/com/oracle/nosql/spring/data/core/NosqlOperations.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface NosqlOperations {
2222
/**
2323
* Creates a table for the given entity type if it doesn't exist.
2424
*/
25-
boolean createTableIfNotExists(NosqlEntityInformation<?, ?> information);
25+
boolean createTableIfNotExists(NosqlEntityInformation<?, ?> entityInformation);
2626

2727
/**
2828
* Drops the given table, information about all saved entities is
@@ -48,27 +48,27 @@ public interface NosqlOperations {
4848
* Inserts the entity into the table, if id generated is used the id
4949
* field must be null or 0.
5050
*/
51-
<T> T insert(T objectToSave);
51+
<T> T insert(T entity);
5252

5353
/**
5454
* Inserts the entity into the given table, if id generated is used the id
5555
* field must be null or 0.
5656
*/
5757
<T, ID> T insert(NosqlEntityInformation<T, ID> entityInformation,
58-
T objectToSave);
58+
T entity);
5959

6060
/**
6161
* Updates the entity into the table. Entity must contain a valid id
6262
* value.
6363
*/
64-
<T> void update(T object);
64+
<T> void update(T entity);
6565

6666
/**
6767
* Updates the entity into the given table. Entity must contain a valid id
6868
* value.
6969
*/
7070
<T, ID> void update(NosqlEntityInformation<T, ID> entityInformation,
71-
T object);
71+
T entity);
7272

7373
/**
7474
* Returns a result of all the entities in the table. Not recommended,

src/main/java/com/oracle/nosql/spring/data/core/NosqlTemplate.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void setApplicationContext(ApplicationContext applicationContext)
8282
throws BeansException {
8383
}
8484

85+
@Override
8586
public String getTableName(Class<?> domainClass) {
8687
Assert.notNull(domainClass, "domainClass should not be null");
8788

@@ -96,12 +97,12 @@ public boolean createTableIfNotExists(
9697

9798
@SuppressWarnings("unchecked")
9899
@Override
99-
public <T> T insert(@NonNull T objectToSave) {
100-
Assert.notNull(objectToSave, "entityClass should not be null");
100+
public <T> T insert(@NonNull T entity) {
101+
Assert.notNull(entity, "entity should not be null");
101102

102103
return insert(getNosqlEntityInformation(
103-
(Class<T>) objectToSave.getClass()),
104-
objectToSave);
104+
(Class<T>) entity.getClass()),
105+
entity);
105106
}
106107

107108
/**
@@ -110,15 +111,15 @@ public <T> T insert(@NonNull T objectToSave) {
110111
*/
111112
@Override
112113
public <T, ID> T insert(NosqlEntityInformation<T, ID> entityInformation,
113-
@NonNull T objectToSave) {
114+
@NonNull T entity) {
114115

115116
Assert.notNull(entityInformation, "Entity information " +
116117
"should not be null.");
117118

118-
Assert.notNull(objectToSave, "objectToSave should not be null");
119+
Assert.notNull(entity, "entity should not be null");
119120

120121
final MapValue row = mappingNosqlConverter.convertObjToRow(
121-
objectToSave, entityInformation.isAutoGeneratedId());
122+
entity, entityInformation.isAutoGeneratedId());
122123

123124
PutResult putRes = doPut(entityInformation, row, false);
124125

@@ -132,10 +133,10 @@ public <T, ID> T insert(NosqlEntityInformation<T, ID> entityInformation,
132133
// for the case when id is autogenerated, the generated value is in
133134
// the result
134135
// id is set to the same object and returned
135-
objectToSave = populateIdIfNecessary(objectToSave, id);
136+
entity = populateIdIfNecessary(entity, id);
136137
}
137138

138-
return objectToSave;
139+
return entity;
139140
}
140141

141142
private <T> T populateIdIfNecessary(T objectToSave, FieldValue id) {
@@ -144,23 +145,24 @@ private <T> T populateIdIfNecessary(T objectToSave, FieldValue id) {
144145

145146
@SuppressWarnings("unchecked")
146147
@Override
147-
public <T> void update(T objectToSave) {
148-
Assert.notNull(objectToSave, "entity should not be null");
148+
public <T> void update(T entity) {
149+
Assert.notNull(entity, "entity should not be null");
149150

150-
update(getNosqlEntityInformation((Class<T>) objectToSave.getClass()),
151-
objectToSave);
151+
update(getNosqlEntityInformation((Class<T>) entity.getClass()),
152+
entity);
152153
}
153154

155+
@Override
154156
public <T, ID> void update(NosqlEntityInformation<T, ID> entityInformation,
155-
T objectToSave) {
157+
T entity) {
156158

157159
Assert.notNull(entityInformation, "Entity information " +
158160
"should not be null.");
159-
Assert.notNull(objectToSave, "objectToSave should not be null");
161+
Assert.notNull(entity, "entity should not be null");
160162

161163
LOG.debug("execute update in table {}", entityInformation.getTableName());
162164
final MapValue row = mappingNosqlConverter
163-
.convertObjToRow(objectToSave, false);
165+
.convertObjToRow(entity, false);
164166

165167
doUpdate(entityInformation, row);
166168
}
@@ -284,11 +286,11 @@ public <T, ID> T findById(NosqlEntityInformation<T, ID> entityInformation,
284286
LOG.debug("execute findById in table {}",
285287
entityInformation.getTableName());
286288

287-
final String idColumName = mappingNosqlConverter
289+
final String idColumnName = mappingNosqlConverter
288290
.getIdProperty(entityInformation.getJavaType()).getName();
289291

290292
final MapValue row = mappingNosqlConverter
291-
.convertIdToPrimaryKey(idColumName, id);
293+
.convertIdToPrimaryKey(idColumnName, id);
292294

293295
GetResult getRes = doGet(entityInformation, row);
294296

@@ -347,6 +349,7 @@ public <T> Iterable<T> findAll(Class<T> entityClass) {
347349
return findAll(getNosqlEntityInformation(entityClass));
348350
}
349351

352+
@Override
350353
public <T> Iterable<T> findAll(
351354
NosqlEntityInformation<T, ?> entityInformation) {
352355
Assert.notNull(entityInformation, "Entity information " +
@@ -554,6 +557,7 @@ public <T, ID> Iterable<T> delete(
554557
}
555558

556559
@SuppressWarnings("unchecked")
560+
@Override
557561
public <S, T> Iterable<T> find(
558562
NosqlEntityInformation<S, ?> entityInformation,
559563
Class<T> targetType,
@@ -571,10 +575,9 @@ public <S, T> Iterable<T> find(
571575
Stream<T> resStream = IterableUtil.getStreamFromIterable(results)
572576
.map(d -> {
573577
Object source = getConverter().read(typeToRead, d);
574-
T result = targetType.isInterface()
578+
return targetType.isInterface()
575579
? projectionFactory.createProjection(targetType, source)
576580
: (T) source;
577-
return result;
578581
});
579582

580583
return IterableUtil.getIterableFromStream(resStream);

src/main/java/com/oracle/nosql/spring/data/core/NosqlTemplateBase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,8 @@ protected Iterable<MapValue> doRunQueryNosqlParams(
309309
}
310310

311311
LOG.debug("Q: {}", query);
312-
Iterable<MapValue> results = doQuery(qReq);
313-
314-
return results;
312+
313+
return doQuery(qReq);
315314
}
316315

317316
protected <T> Iterable<MapValue> doExecuteMapValueQuery(NosqlQuery query,

src/main/java/com/oracle/nosql/spring/data/core/ReactiveNosqlOperations.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface ReactiveNosqlOperations {
3333
* different than ACTIVE.
3434
*/
3535
Mono<Boolean> createTableIfNotExists(
36-
NosqlEntityInformation<?, ?> information);
36+
NosqlEntityInformation<?, ?> entityInformation);
3737

3838
/**
3939
* Drops table and returns true if result indicates table state changed to
@@ -55,15 +55,15 @@ <T, ID> Mono<T> findById(NosqlEntityInformation<T, ID> entityInformation,
5555
<T, ID> Flux<T> findAllById(NosqlEntityInformation<T, ID> entityInformation,
5656
Publisher<ID> idStream);
5757

58-
<T> Mono<T> insert(T objectToSave);
58+
<T> Mono<T> insert(T entity);
5959

60-
<S, ID> Mono<S> insert(NosqlEntityInformation<?, ID> entityInformation,
61-
S objectToSave);
60+
<T, ID> Mono<T> insert(NosqlEntityInformation<?, ID> entityInformation,
61+
T entity);
6262

63-
<T> Mono<T> update(T object);
63+
<T> Mono<T> update(T entity);
6464

65-
<S, ID> Mono<S> update(NosqlEntityInformation<?, ID> entityInformation,
66-
S object);
65+
<T, ID> Mono<T> update(NosqlEntityInformation<?, ID> entityInformation,
66+
T entity);
6767

6868
<ID> Mono<Void> deleteById(NosqlEntityInformation<?, ID> entityInformation,
6969
ID id);

0 commit comments

Comments
 (0)