package info.bukova.isspst.data;

import info.bukova.isspst.StringUtils;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class UsersAddress {

	@Column(name = "STREET")
	private String street;
	@Column(name = "HOUSE_NUMBER")
	private String houseNumber;
	@Column(name = "ZIP_CODE")
	private String zipCode;
	@Column(name = "CITY")
	private String city;

	public String getStreet() {
		return street;
	}

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

	public String getHouseNumber() {
		return houseNumber;
	}

	public void setHouseNumber(String houseNumber) {
		this.houseNumber = houseNumber;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	
	public String toString() {
		List<String> list = new ArrayList<String>();
		list.add(this.street);
		list.add(this.houseNumber);
		final String s1 = StringUtils.joinNotEmpty(list, " ");

		list.clear();
		list.add(this.zipCode);
		list.add(this.city);
		final String s2 = StringUtils.joinNotEmpty(list, " ");

		list.clear();
		list.add(s1);
		list.add(s2);
		final String s = StringUtils.joinNotEmpty(list, ", ");

		return s;
	}
}
