DATACASS-483 - Polishing.

Replace explicit type arguments with diamond syntax. Use Collections.empty…() instead of Collections.EMPTY_…
This commit is contained in:
Mark Paluch
2017-07-28 13:54:50 +02:00
parent de343e2d6c
commit 14a5f9f41b
7 changed files with 15 additions and 22 deletions

View File

@@ -189,7 +189,7 @@ public class CassandraMappingBeanFactoryPostProcessor implements BeanFactoryPost
private Collection<String> getNames(Class<?>[] types) {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (Class<?> type : types) {
names.add(type.getName());

View File

@@ -15,9 +15,9 @@
*/
package org.springframework.data.cassandra.core.mapping;
import static org.springframework.data.cassandra.core.cql.CqlIdentifier.cqlId;
import static org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification.createTable;
import static org.springframework.data.cassandra.core.mapping.CassandraSimpleTypeHolder.getDataTypeFor;
import static org.springframework.data.cassandra.core.cql.CqlIdentifier.*;
import static org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification.*;
import static org.springframework.data.cassandra.core.mapping.CassandraSimpleTypeHolder.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -95,7 +95,7 @@ public class CassandraMappingContext
public CassandraMappingContext() {
setCustomConversions(
new CustomConversions(StoreConversions.of(CassandraSimpleTypeHolder.HOLDER), Collections.EMPTY_LIST));
new CustomConversions(StoreConversions.of(CassandraSimpleTypeHolder.HOLDER), Collections.emptyList()));
setSimpleTypeHolder(CassandraSimpleTypeHolder.HOLDER);
}

View File

@@ -91,7 +91,7 @@ public class SimpleCassandraRepository<T, ID> implements CassandraRepository<T,
Assert.notNull(entities, "The given Iterable of entities must not be null");
List<S> result = new ArrayList<S>();
List<S> result = new ArrayList<>();
for (S entity : entities) {

View File

@@ -15,10 +15,8 @@
*/
package org.springframework.data.cassandra.core.mapping;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.io.Serializable;
import java.util.Collection;
@@ -29,7 +27,6 @@ import java.util.NoSuchElementException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.annotation.Id;
@@ -373,7 +370,7 @@ public class CassandraMappingContextUnitTests {
@Test // DATACASS-296
public void shouldCreatePersistentEntityIfNoConversionRegistered() {
mappingContext.setCustomConversions(new CassandraCustomConversions(Collections.EMPTY_LIST));
mappingContext.setCustomConversions(new CassandraCustomConversions(Collections.emptyList()));
assertThat(mappingContext.shouldCreatePersistentEntityFor(ClassTypeInformation.from(Human.class))).isTrue();
}

View File

@@ -298,7 +298,7 @@ public class CreateTableSpecificationBasicCassandraMappingContextUnitTests {
private CreateTableSpecification getCreateTableSpecificationFor(Class<?> persistentEntityClass) {
CassandraCustomConversions customConversions = new CassandraCustomConversions(Collections.EMPTY_LIST);
CassandraCustomConversions customConversions = new CassandraCustomConversions(Collections.emptyList());
ctx.setCustomConversions(customConversions);
CassandraPersistentEntity<?> persistentEntity = ctx.getRequiredPersistentEntity(persistentEntityClass);

View File

@@ -200,7 +200,7 @@ public class StringBasedCassandraQueryUnitTests {
SimpleStatement actual = cassandraQuery.createQuery(accessor);
assertThat(actual.toString()).isEqualTo("SELECT * FROM person WHERE lastname IN (?);");
assertThat(actual.getObject(0)).isEqualTo(new HashSet<String>(Arrays.asList("White", "Heisenberg")));
assertThat(actual.getObject(0)).isEqualTo(new HashSet<>(Arrays.asList("White", "Heisenberg")));
}
@Test // DATACASS-117

View File

@@ -429,14 +429,10 @@ public class CassandraRule extends ExternalResource {
this.cluster = cluster;
this.session = session;
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
session.close();
cluster.close();
}
});
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
session.close();
cluster.close();
}));
}
}
}