feat: Using text blocks instead of String literals (#2791)

This commit is contained in:
Manoj Chowdary
2024-03-10 15:09:25 +05:30
committed by GitHub
parent 90f5b38a45
commit e377047a69
10 changed files with 87 additions and 48 deletions
@@ -24,7 +24,6 @@
*/
package com.iluwatar.embedded.value;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
@@ -73,7 +72,7 @@ public class App {
}
// Initially, database is empty
LOGGER.info("Orders Query: {}", dataSource.queryOrders().collect(Collectors.toList()));
LOGGER.info("Orders Query: {}", dataSource.queryOrders().toList());
//Insert orders where shippingAddress is mapped to different columns of the same table
dataSource.insertOrder(order1);
@@ -83,7 +82,7 @@ public class App {
// Query orders.
// We'll create ShippingAddress object from city, state, pincode values from the table and add it to Order object
LOGGER.info("Orders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n");
LOGGER.info("Orders Query: {}", dataSource.queryOrders().toList() + "\n");
//Query order by given id
LOGGER.info("Query Order with id=2: {}", dataSource.queryOrder(2));
@@ -93,7 +92,7 @@ public class App {
//Since we'd mapped address in the same table, deleting order will also take out the shipping address details.
LOGGER.info("Remove Order with id=1");
dataSource.removeOrder(1);
LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n");
LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().toList() + "\n");
//After successful demonstration of the pattern, drop the table
if (dataSource.deleteSchema()) {
@@ -87,7 +87,7 @@ public class DataSource implements DataSourceInterface {
var resultSet = getschema.executeQuery(GET_SCHEMA);
var sb = new StringBuilder();
while (resultSet.next()) {
sb.append("Col name: " + resultSet.getString(1) + ", Col type: " + resultSet.getString(2) + "\n");
sb.append("Col name: ").append(resultSet.getString(1)).append(", Col type: ").append(resultSet.getString(2)).append("\n");
}
getschema.close();
return sb.toString();