Commit de9517a1 by Patryk Czarnik

Adnotacje JAXB

parent a230fb53
......@@ -2,11 +2,17 @@ package sklep.model;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
public class Customer {
@XmlAttribute
private String email;
private String name;
@XmlElement(name="phone")
private String phoneNumber;
private String address;
@XmlElement(name="postal-code")
private String postalCode;
private String city;
......
......@@ -7,15 +7,25 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
public class Order {
@XmlAttribute(name="id")
private Integer orderId;
@XmlAttribute(name="customer-id")
private String customerEmail;
@XmlElement(name="order-date")
private LocalDateTime orderDate;
@XmlAttribute(name="status")
private Status orderStatus;
@XmlElementWrapper(name="products")
@XmlElement(name="product")
public final List<OrderProduct> products = new ArrayList<>();
public Order() {
......
......@@ -3,13 +3,19 @@ package sklep.model;
import java.math.BigDecimal;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
public class OrderProduct {
@XmlAttribute(name="order-id")
private Integer orderId;
@XmlAttribute(name="product-id")
private Integer productId;
private int quantity;
@XmlElement(name="actual-price")
private BigDecimal actualPrice;
public OrderProduct() {
......
......@@ -3,8 +3,14 @@ package sklep.model;
import java.math.BigDecimal;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
public class Product {
@XmlAttribute(name="id")
private Integer productId;
@XmlElement(name="name")
private String productName;
private BigDecimal price;
private BigDecimal vat;
......
@XmlAccessorType(XmlAccessType.FIELD)
package sklep.model;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAccessType;
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