package net.oxmall.admin.module.member.bean.form;

import lombok.Data;
import lombok.EqualsAndHashCode;
import net.oxmall.admin.module.base.bean.DataForm;
import net.oxmall.base.entities.MemberAddress;
import net.oxmall.base.entities.MemberProfile;
import net.oxmall.base.entities.MemberRank;

import java.util.*;

/**
 * @author rocky.hu
 * @date Nov 10, 2016 9:32:04 PM
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MemberDataForm extends DataForm {
    private String username;
    private String email;
    private String password;
    private String nickname;
    private String mobile;
    private MemberProfile.Gender gender;
    private String avatar;
    private Date birthday;

    private MemberRank memberRank;
    private Set<MemberAddress> memberAddresses = new HashSet<>();
    private List<MemberAddress> addresses = new ArrayList<>();

    public void setUsername(String username)
    {
        this.username = username == null ? username : username.toLowerCase();
    }

    public void setMemberAddresses(Set<MemberAddress> memberAddresses)
    {
        this.memberAddresses = memberAddresses;
        this.addresses = new ArrayList<>(memberAddresses);
    }

    public void setAddresses(List<MemberAddress> addresses)
    {
        this.addresses = addresses;
        this.memberAddresses = new HashSet<>(addresses);
    }
}
