net.groupbuy.entity.Receiver.java Source code

Java tutorial

Introduction

Here is the source code for net.groupbuy.entity.Receiver.java

Source

/*
 * Copyright 2005-2013 shopxx.net. All rights reserved.
 * Support: http://www.shopxx.net
 * License: http://www.shopxx.net/license
 */
package net.groupbuy.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Entity - ?
 * 
 * @author SHOP++ Team
 * @version 3.0
 */
@Entity
@Table(name = "xx_receiver")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_receiver_sequence")
public class Receiver extends BaseEntity {

    private static final long serialVersionUID = 2673602067029665976L;

    /** ?? */
    public static final Integer MAX_RECEIVER_COUNT = 8;

    /**  */
    private String consignee;

    /** ?? */
    private String areaName;

    /** ? */
    private String address;

    /**  */
    private String zipCode;

    /** ? */
    private String phone;

    /** ? */
    private Boolean isDefault;

    /**  */
    private Area area;

    /**  */
    private Member member;

    /**
     * ?
     * 
     * @return 
     */
    @JsonProperty
    @NotEmpty
    @Length(max = 200)
    @Column(nullable = false)
    public String getConsignee() {
        return consignee;
    }

    /**
     * 
     * 
     * @param consignee
     *            
     */
    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    /**
     * ???
     * 
     * @return ??
     */
    @JsonProperty
    @Column(nullable = false)
    public String getAreaName() {
        return areaName;
    }

    /**
     * ??
     * 
     * @param areaName
     *            ??
     */
    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    /**
     * ??
     * 
     * @return ?
     */
    @JsonProperty
    @NotEmpty
    @Length(max = 200)
    @Column(nullable = false)
    public String getAddress() {
        return address;
    }

    /**
     * ?
     * 
     * @param address
     *            ?
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * ?
     * 
     * @return 
     */
    @JsonProperty
    @NotEmpty
    @Length(max = 200)
    @Column(nullable = false)
    public String getZipCode() {
        return zipCode;
    }

    /**
     * 
     * 
     * @param zipCode
     *            
     */
    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    /**
     * ??
     * 
     * @return ?
     */
    @JsonProperty
    @NotEmpty
    @Length(max = 200)
    @Column(nullable = false)
    public String getPhone() {
        return phone;
    }

    /**
     * ?
     * 
     * @param phone
     *            ?
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * ??
     * 
     * @return ?
     */
    @JsonProperty
    @NotNull
    @Column(nullable = false)
    public Boolean getIsDefault() {
        return isDefault;
    }

    /**
     * ?
     * 
     * @param isDefault
     *            ?
     */
    public void setIsDefault(Boolean isDefault) {
        this.isDefault = isDefault;
    }

    /**
     * ?
     * 
     * @return 
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    public Area getArea() {
        return area;
    }

    /**
     * 
     * 
     * @param area
     *            
     */
    public void setArea(Area area) {
        this.area = area;
    }

    /**
     * ?
     * 
     * @return 
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, updatable = false)
    public Member getMember() {
        return member;
    }

    /**
     * 
     * 
     * @param member
     *            
     */
    public void setMember(Member member) {
        this.member = member;
    }

    /**
     * ???
     */
    @PrePersist
    public void prePersist() {
        if (getArea() != null) {
            setAreaName(getArea().getFullName());
        }
    }

    /**
     * ??
     */
    @PreUpdate
    public void preUpdate() {
        if (getArea() != null) {
            setAreaName(getArea().getFullName());
        }
    }

}