www.pudn.com > dangdang.zip > OrderItem.java, change:2006-06-25,size:1128b


package com.tarena.dangdang.entity; 
 
import java.util.Set; 
 
public class OrderItem { 
	private Integer id; 
	private Product product; 
	private int amount; 
	private double price; 
 
	public Integer getId() { 
		return id; 
	} 
 
	public void setId(Integer id) { 
		this.id = id; 
	} 
 
	public Product getProduct() { 
		return product; 
	} 
 
	public void setProduct(Product product) { 
		this.product = product; 
	} 
 
	public int getAmount() { 
		return amount; 
	} 
 
	public void setAmount(int amount) { 
		this.amount = amount; 
	} 
 
	public double getPrice() { 
		return price; 
	} 
 
	public void setPrice(double price) { 
		this.price = price; 
	} 
	 
	public void addProduct(Product product){ 
	   this.product = product; 
	   product.getOrderItems().add(this); 
	} 
	 
	public void removeProduct(Product product){ 
	  this.product = null; 
	  product.getOrderItems().remove(this); 
	} 
 
	public void removeAll(){ 
		Set<OrderItem> orderItems = product.getOrderItems(); 
        for(OrderItem oi:orderItems){ 
             oi.setProduct(null);   	 
        } 
        product.getOrderItems().clear(); 
    } 
}