Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/lab-java-maven.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions solution-lab-2.02-maven/order-data/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>solution-lab-2.02-maven</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>order-data</artifactId>

<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.example;

public class Customer {
private String name;
private String email;

public Customer(String name, String email) {
this.name = name;
this.email = email;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

@Override
public String toString() {
return "{" +
"\nname: " + name +
",\nemail: " + email +
",\n}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.example;

import com.google.gson.annotations.SerializedName;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class Order {
@SerializedName("order_id")
private UUID id;
private Customer customer;
private List<OrderItem> items=new ArrayList<>();
private BigDecimal total;

public Order(UUID id, Customer customer, List<OrderItem> items, BigDecimal total) {
this.id = id;
this.customer = customer;
this.items = items;
this.total = total;
}

public UUID getId() {
return id;
}

public void setId(UUID id) {
this.id = id;
}

public Customer getCustomer() {
return customer;
}

public void setCustomer(Customer customer) {
this.customer = customer;
}

public List<OrderItem> getItems() {
return items;
}

public void setItems(List<OrderItem> items) {
this.items = items;
}

public BigDecimal getTotal() {
return total;
}

public void setTotal(BigDecimal total) {
this.total = total;
}

@Override
public String toString() {
return "{" +
"\norder_id: " + id +
",\ncustomer: "+customer.toString() +
",\nitems: " + items.toString() +
",\ntotal :" + total +
"\n}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.example;

import com.google.gson.annotations.SerializedName;

import java.util.UUID;

public class OrderItem {
@SerializedName("product_id")
private UUID id;
@SerializedName("product_name")
private String name;
private int quantity;
private double price;

public OrderItem(UUID id, String name, int quantity, double price) {
this.id = id;
this.name = name;
this.quantity = quantity;
this.price = price;
}

public UUID getId() {
return id;
}

public void setId(UUID id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

@Override
public String toString() {
return "{" +
"\nproduct_id: " + id +
",\nproduct_name: '" + name + '\'' +
",\nquantity: " + quantity +
",\nprice: " + price +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.example;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

public class OrderProcessor {
static void main() throws FileNotFoundException {
FileReader reader= new FileReader("C:\\Users\\Administrator\\IdeaProjects\\lab-java-maven\\solution-lab-2.02-maven\\order-data\\src\\main\\java\\org\\example\\order.json");
Gson gson=new Gson();
Order order=gson.fromJson(reader, Order.class);
System.out.println(order.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"customer": {
"name": "Alice Johnson",
"email": "alice@example.com"
},
"items": [
{
"product_id": "123e4567-e89b-12d3-a456-426614174000",
"product_name": "Wireless Mouse",
"quantity": 2,
"price": 25.00
},
{
"product_id": "987e6543-e21b-12d3-a456-426614174111",
"product_name": "Keyboard",
"quantity": 1,
"price": 50.0
}
],
"total": 100.0
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifactId=order-data
groupId=org.example
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org\example\Customer.class
org\example\Order.class
org\example\OrderProcessor.class
org\example\OrderItem.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\Customer.java
C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\Order.java
C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\OrderItem.java
C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\OrderProcessor.java
Binary file not shown.
27 changes: 27 additions & 0 deletions solution-lab-2.02-maven/order-logic/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>solution-lab-2.02-maven</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>order-logic</artifactId>

<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>order-data</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
Loading