order.java

来自「达内Java培训实训项目ECPORT原码。 包括逐步优化的四个版本: 简单工」· Java 代码 · 共 100 行

JAVA
100
字号
package com.royee.ecport.pojo;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class Order extends EntityBase {
	private static final long serialVersionUID = 60056479844866741L;
	private Long oid;
	private Double cost;
	private User user;
	private OrderStatus status;
	private Payway payway;
	private Set<OrderLine> orderLines;
	
	public Long getOid() {
		return oid;
	}
	public void setOid(Long oid) {
		this.oid = oid;
	}
	public Double getCost() {
		return cost;
	}
	public void setCost(Double cost) {
		this.cost = cost;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public OrderStatus getStatus() {
		return status;
	}
	public void setStatus(OrderStatus status) {
		this.status = status;
	}
	public Payway getPayway() {
		return payway;
	}
	public void setPayway(Payway payway) {
		this.payway = payway;
	}
	public Set<OrderLine> getOrderLines() {
		return orderLines;
	}
	public void setOrderLines(Set<OrderLine> orderLines) {
		this.orderLines = orderLines;
	}
	
	//业务方法
	public void addOrderLine(OrderLine ol){
		if(orderLines==null)
			orderLines=new HashSet<OrderLine>();
		
		ol.setOrder(this);
		orderLines.add(ol);
	}
	
	public void addOrderLines(Collection<OrderLine> olist){
		if(orderLines==null)
			orderLines=new HashSet<OrderLine>();
		
		for(OrderLine ol:olist){
			addOrderLine(ol);
		}
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((oid == null) ? 0 : oid.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Order other = (Order) obj;
		if (oid == null) {
			if (other.oid != null)
				return false;
		} else if (!oid.equals(other.oid))
			return false;
		return true;
	}
	
	


	
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?