Search in sources :

Example 1 with Customer

use of com.model.Customer in project java-apply by javachengwc.

the class Main2 method main.

public static void main(String[] args) throws Exception {
    Customer customer = new Customer(111L, "张三");
    Order order1 = new Order(1L, new Date());
    Order order2 = new Order(2L, new Date());
    Item item11 = new Item(1, 11L);
    Item item21 = new Item(2, 21L);
    Address address = new Address("450000", "瑞达路XX#", true);
    customer.setAddress(address);
    customer.getOrderList().add(order1);
    customer.getOrderList().add(order2);
    order1.getItemList().add(item11);
    order2.getItemList().add(item21);
    Serializer serializer = new Persister();
    File result = new File("E:/tmp/customer.xml");
    serializer.write(customer, result);
    Customer _obj = serializer.read(Customer.class, result);
    System.out.println(_obj.getName());
    System.out.println(_obj.getOrderList().get(0).getCdate());
}
Also used : Order(com.model.Order) Item(com.model.Item) Address(com.model.Address) Customer(com.model.Customer) Persister(org.simpleframework.xml.core.Persister) File(java.io.File) Date(java.util.Date)

Aggregations

Address (com.model.Address)1 Customer (com.model.Customer)1 Item (com.model.Item)1 Order (com.model.Order)1 File (java.io.File)1 Date (java.util.Date)1 Persister (org.simpleframework.xml.core.Persister)1