package model.adresses;

import java.util.Objects;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import model.AbstractEntity;

/**
 *
 * @author Patrick
 */
@MappedSuperclass
public class Address extends AbstractEntity{
    
    //Land
    @NotNull(message = "Land darf nicht null sein")
    private String country;
    
    //Straßenname
    @NotNull(message = "Strasse darf nicht null sein")
    private String street;
    
    //Hausnummer
    @NotNull(message = "Hausnummer darf nicht null sein")
    private String number;
    
    //Zusatz
    private String extra;
    
    //PLZ
    @NotNull(message = "PLZ darf nicht null sein")
    private Integer postnumber;
    
    //Bundesland
    @NotNull(message = "Bundesland darf nicht null sein")
    private String county;
    
    //Ort
    @NotNull(message = "Ort darf nicht null sein")
    private String place;
    
    private String contact;
    
    private String comment;

    public Address() {
    }

    public Address(String street, String number, String extra, Integer postnumber, String county, String place) {
        this.street = street;
        this.number = number;
        this.extra = extra;
        this.postnumber = postnumber;
        this.county = county;
        this.place = place;
    }

    public Address(String country, String street, String number, String extra, Integer postnumber, String county, String place) {
        this.country = country;
        this.street = street;
        this.number = number;
        this.extra = extra;
        this.postnumber = postnumber;
        this.county = county;
        this.place = place;
    }

    public Address(String country, String street, String number, String extra, Integer postnumber, String county, String place, String contact, String comment) {
        this.country = country;
        this.street = street;
        this.number = number;
        this.extra = extra;
        this.postnumber = postnumber;
        this.county = county;
        this.place = place;
        this.contact = contact;
        this.comment = comment;
    }
    
    public Address(Address toCopyAddress){
        this.country = toCopyAddress.getCountry();
        this.street = toCopyAddress.getStreet();
        this.number = toCopyAddress.getNumber();
        this.extra = toCopyAddress.getExtra();
        this.postnumber = toCopyAddress.getPostnumber();
        this.county = toCopyAddress.getCounty();
        this.place = toCopyAddress.getPlace();
        this.contact = toCopyAddress.getContact();
        this.comment = toCopyAddress.getComment();
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + Objects.hashCode(this.country);
        hash = 83 * hash + Objects.hashCode(this.street);
        hash = 83 * hash + Objects.hashCode(this.number);
        hash = 83 * hash + Objects.hashCode(this.extra);
        hash = 83 * hash + Objects.hashCode(this.postnumber);
        hash = 83 * hash + Objects.hashCode(this.county);
        hash = 83 * hash + Objects.hashCode(this.place);
        hash = 83 * hash + Objects.hashCode(this.contact);
        hash = 83 * hash + Objects.hashCode(this.comment);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Address other = (Address) obj;
        if (!Objects.equals(this.country, other.country)) {
            return false;
        }
        if (!Objects.equals(this.street, other.street)) {
            return false;
        }
        if (!Objects.equals(this.number, other.number)) {
            return false;
        }
        if (!Objects.equals(this.extra, other.extra)) {
            return false;
        }
        if (!Objects.equals(this.county, other.county)) {
            return false;
        }
        if (!Objects.equals(this.place, other.place)) {
            return false;
        }
        if (!Objects.equals(this.comment, other.comment)) {
            return false;
        }
        return Objects.equals(this.postnumber, other.postnumber);
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public Integer getPostnumber() {
        return postnumber;
    }

    public void setPostnumber(Integer postnumber) {
        this.postnumber = postnumber;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}
