package com.ichir.projects.beans;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.ichir.projects.jaxb.DateAdapter;

@XmlRootElement(name="person")
@XmlAccessorType(XmlAccessType.FIELD)
public class Person {

	@XmlElement(name="civility")
	private Civility civility;
	
	@XmlElement(name="sex", defaultValue="M")
	private Sex sex;

	@XmlElement(name="birthDate")
	@XmlJavaTypeAdapter(DateAdapter.class)
	private Date birth;

	@XmlElement
	private Parents parents;

	/**
	 * @return the sex
	 */
	public Sex getSex() {
		return sex;
	}

	/**
	 * @param sex the sex to set
	 */
	public void setSex(Sex sex) {
		this.sex = sex;
	}

	/**
	 * @return the civility
	 */
	public Civility getCivility() {
		return civility;
	}

	/**
	 * @param civility the civility to set
	 */
	public void setCivility(Civility civility) {
		this.civility = civility;
	}

	/**
	 * @return the birth
	 */
	public Date getBirth() {
		return birth;
	}

	/**
	 * @param birth the birth to set
	 */
	public void setBirth(Date birth) {
		this.birth = birth;
	}

	@Override
	public String toString() {
		return String.format("Person: %s, sex: %s, date of birth: %s, ", civility, sex, birth);
	}

	/**
	 * @return the parents
	 */
	public Parents getParents() {
		return parents;
	}

	/**
	 * @param parents the parents to set
	 */
	public void setParents(Parents parents) {
		this.parents = parents;
	}
}
