DATACASS-546 - Polishing.

Remove unnecessary throws declarations. Reformat code.
This commit is contained in:
Mark Paluch
2018-04-16 16:44:24 +02:00
parent 7cba0e2260
commit d60fb9c928
4 changed files with 26 additions and 22 deletions

View File

@@ -79,8 +79,9 @@ public class CassandraPersistentEntitySchemaCreator {
*/
public void createTables(boolean ifNotExists) {
createTableSpecifications(ifNotExists).forEach(specification -> this.cassandraAdminOperations.getCqlOperations()
.execute(CreateTableCqlGenerator.toCql(specification)));
createTableSpecifications(ifNotExists).stream() //
.map(CreateTableCqlGenerator::toCql) //
.forEach(cql -> this.cassandraAdminOperations.getCqlOperations().execute(cql));
}
/**
@@ -91,8 +92,9 @@ public class CassandraPersistentEntitySchemaCreator {
*/
protected List<CreateTableSpecification> createTableSpecifications(boolean ifNotExists) {
return this.mappingContext.getTableEntities().stream()
.map(entity -> this.mappingContext.getCreateTableSpecificationFor(entity).ifNotExists(ifNotExists))
return this.mappingContext.getTableEntities() //
.stream() //
.map(entity -> this.mappingContext.getCreateTableSpecificationFor(entity).ifNotExists(ifNotExists)) //
.collect(Collectors.toList());
}
@@ -103,8 +105,9 @@ public class CassandraPersistentEntitySchemaCreator {
*/
public void createIndexes(boolean ifNotExists) {
createIndexSpecifications(ifNotExists).forEach(specification -> this.cassandraAdminOperations.getCqlOperations()
.execute(CreateIndexCqlGenerator.toCql(specification)));
createIndexSpecifications(ifNotExists).stream() //
.map(CreateIndexCqlGenerator::toCql) //
.forEach(cql -> this.cassandraAdminOperations.getCqlOperations().execute(cql));
}
/**
@@ -115,9 +118,10 @@ public class CassandraPersistentEntitySchemaCreator {
*/
protected List<CreateIndexSpecification> createIndexSpecifications(boolean ifNotExists) {
return this.mappingContext.getTableEntities().stream()
.flatMap(entity -> this.mappingContext.getCreateIndexSpecificationsFor(entity).stream())
.peek(it -> it.ifNotExists(ifNotExists))
return this.mappingContext.getTableEntities() //
.stream() //
.flatMap(entity -> this.mappingContext.getCreateIndexSpecificationsFor(entity).stream()) //
.peek(it -> it.ifNotExists(ifNotExists)) //
.collect(Collectors.toList());
}
@@ -128,8 +132,9 @@ public class CassandraPersistentEntitySchemaCreator {
*/
public void createUserTypes(boolean ifNotExists) {
createUserTypeSpecifications(ifNotExists).forEach(specification ->
this.cassandraAdminOperations.getCqlOperations().execute(CreateUserTypeCqlGenerator.toCql(specification)));
createUserTypeSpecifications(ifNotExists).stream() //
.map(CreateUserTypeCqlGenerator::toCql) //
.forEach(cql -> this.cassandraAdminOperations.getCqlOperations().execute(cql));
}
/**

View File

@@ -78,11 +78,11 @@ public class CassandraPersistentEntitySchemaDropper {
*/
public void dropTables(boolean dropUnused) {
this.cassandraAdminOperations.getKeyspaceMetadata().getTables()
.stream()
.map(AbstractTableMetadata::getName)
.map(CqlIdentifier::of)
.filter(table -> dropUnused || this.mappingContext.usesTable(table))
this.cassandraAdminOperations.getKeyspaceMetadata() //
.getTables() //
.stream() //
.map(AbstractTableMetadata::getName) //
.map(CqlIdentifier::of).filter(table -> dropUnused || this.mappingContext.usesTable(table)) //
.forEach(this.cassandraAdminOperations::dropTable);
}

View File

@@ -43,7 +43,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe
CassandraMappingContext context = new CassandraMappingContext();
@Before
public void setUp() throws Exception {
public void setUp() {
context.setUserTypeResolver(typeName -> {
// make sure that calls to this method pop up. Calling UserTypeResolver while resolving

View File

@@ -59,7 +59,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe
// DATACASS-355
@Before
public void setUp() throws Exception {
public void setUp() {
context.setUserTypeResolver(typeName -> metadata.getUserType(typeName.toCql()));
@@ -69,7 +69,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe
}
@Test // DATACASS-355, DATACASS-546
public void shouldDropTypesInOrderOfDependencies() throws Exception {
public void shouldDropTypesInOrderOfDependencies() {
when(metadata.getUserTypes()).thenReturn(Arrays.asList(universetype, moontype, planettype));
@@ -101,7 +101,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe
}
@Test // DATACASS-355
public void shouldDropTables() throws Exception {
public void shouldDropTables() {
context.setInitialEntitySet(Collections.singleton(Person.class));
context.afterPropertiesSet();
@@ -120,7 +120,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe
}
@Test
public void dropTablesShouldRetainUnusedTables() throws Exception {
public void dropTablesShouldRetainUnusedTables() {
context.setInitialEntitySet(Collections.singleton(Person.class));
context.afterPropertiesSet();
@@ -147,5 +147,4 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe
inOrder.verifyNoMoreInteractions();
}
}