Commit 95c640a8 authored by Bhargava Rellu's avatar Bhargava Rellu

lombok

parent 4d431add
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Gradle Imported" enabled="true">
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.22/9c08ea24c6eb714e2d6170e8122c069a0ba9aacf/lombok-1.18.22.jar" />
</processorPath>
<module name="OrderManagementForRetailStore.main" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
......@@ -12,11 +12,13 @@ repositories {
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.16'
// https://mvnrepository.com/artifact/org.projectlombok/lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2'
}
test {
......
......@@ -7,7 +7,6 @@ import java.sql.SQLException;
import java.util.Scanner;
import java.util.logging.Logger;
import static com.retail_store.order_management.utils.Database.getConnection;
import static com.retail_store.order_management.utils.Utility.getInt;
public class OrderManagement {
......@@ -61,11 +60,6 @@ public class OrderManagement {
flag = false;
break;
case 5:
try {
getConnection().close();
} catch (SQLException e) {
logger.warning(e.getMessage());
}
logger.info(menu);
break;
default:
......
package com.retail_store.order_management.model;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@Getter
@AllArgsConstructor
public class Order {
private String orderId;
private LocalDate orderDate;
......@@ -15,45 +19,6 @@ public class Order {
private double totalBill;
List<OrderedProduct> productsList;
public Order(String orderId, LocalDate orderDate, LocalTime localTime, String customerName, String phoneNumber, double totalBill, List<OrderedProduct> productsList) {
this.orderId = orderId;
this.orderDate = orderDate;
this.localTime = localTime;
this.customerName = customerName;
this.phoneNumber = phoneNumber;
this.totalBill = totalBill;
this.productsList = productsList;
}
public String getOrderId() {
return orderId;
}
public LocalDate getOrderDate() {
return orderDate;
}
public LocalTime getLocalTime() {
return localTime;
}
public String getCustomerName() {
return customerName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public double getTotalBill() {
return totalBill;
}
public List<OrderedProduct> getProductsList() {
return productsList;
}
public String showOrder() {
return "order id : " + orderId + "\nCustomer name: " + customerName + "\tPhone number: " + phoneNumber + "\nDate: " + orderDate + "\tTime: " + localTime + "\n Total Bill: " + totalBill;
}
......@@ -62,7 +27,4 @@ public class Order {
return productsList.stream().map(product -> product.getId() + "\t" + product.getName() + "\n" + product.getCategory() + "\t" + product.getSize() + "\n" + product.getQuantity() + "\t" + product.getPrice() + "\t" + product.getQuantity() * product.getPrice()).reduce("", (productsList, product) -> productsList + "\n" + product);
}
public String orderIdGenerator() {
return Arrays.stream(UUID.randomUUID().toString().split("-")).findFirst().get() + "#" + Order.class.getSimpleName();
}
}
......@@ -5,7 +5,12 @@ import com.retail_store.order_management.constants.Category;
import com.retail_store.order_management.constants.Color;
import com.retail_store.order_management.constants.Gender;
import com.retail_store.order_management.constants.Size;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class OrderedProduct {
private String id;
private String name;
......@@ -16,49 +21,6 @@ public class OrderedProduct {
private Size size;
private int quantity;
public String getId() {
return id;
}
public String getName() {
return name;
}
public Category getCategory() {
return category;
}
public Color getColor() {
return color;
}
public double getPrice() {
return price;
}
public Gender getIdealFor() {
return idealFor;
}
public Size getSize() {
return size;
}
public int getQuantity() {
return quantity;
}
public OrderedProduct(String id, String name, Category category, Color color, double price, Gender idealFor, Size size, int quantity) {
this.id = id;
this.name = name;
this.category = category;
this.color = color;
this.price = price;
this.idealFor = idealFor;
this.size = size;
this.quantity = quantity;
}
@Override
public String toString() {
return "OrderedProduct{" +
......
......@@ -5,9 +5,14 @@ import com.retail_store.order_management.constants.Category;
import com.retail_store.order_management.constants.Color;
import com.retail_store.order_management.constants.Gender;
import com.retail_store.order_management.constants.Size;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
@Getter
@AllArgsConstructor
public class Product {
private String id;
private String name;
......@@ -17,44 +22,6 @@ public class Product {
private Gender idealFor;
private Map<Size, Integer> size;
public Product(String id, String name, Category category, Color color, double price, Gender idealFor, Map<Size, Integer> size) {
this.id = id;
this.name = name;
this.category = category;
this.color = color;
this.price = price;
this.idealFor = idealFor;
this.size = size;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public Category getCategory() {
return category;
}
public Color getColor() {
return color;
}
public double getPrice() {
return price;
}
public Gender getIdealFor() {
return idealFor;
}
public Map<Size, Integer> getSize() {
return size;
}
public String getProductSizeAvailability() {
return size.entrySet().stream().map(entry -> entry.getKey() + " - " + entry.getValue()).reduce("", (sizes, size) -> sizes + "\n" + size.toString());
}
......
......@@ -20,5 +20,4 @@ public interface ProductFilter {
public Map<Integer, Product> getProductsByGenderAndCategory(Gender gender, Category category);
// public Map<Integer, Product> getProductsByGenderAndColor(Collection<Product> productList, Color color);
}
......@@ -26,7 +26,7 @@ public class RetailStoreService implements RetailStore, ProductFilter {
String id = productIdGenerator();
getLogger().info("Enter Product details \n Enter Product Name");
String name = getScanner().nextLine();
getLogger().info(name);
// getLogger().info(name);
Category category = getCategory(true, "Enter Product Category");
Color color = getColor(true, "Select color of the product");
double price = getDouble(true, "Enter price of the product");
......@@ -376,5 +376,4 @@ public class RetailStoreService implements RetailStore, ProductFilter {
}
return ordersMenu;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment