/**
 * Multimud Helper.
 * 
 * Copyright (C) 2009 Benjamin Lerman<br>
 * Copyright (C) 2009 Jacques ???
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.ambre.multimud_helper.bean;

import java.io.Serializable;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import org.hibernate.validator.NotNull;

/**
 * a trainer in the mud.
 */
@Entity
public class Trainer implements Nameable, Serializable {

    /**
     * serial version uid for {@link java.io.Serializable}.
     */
    private static final long serialVersionUID = 1L;

    /**
     * the primary key of the object.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    /**
     * the name of the trainer.
     */
    @NotNull
    @Column(unique = true)
    private String name;

    /**
     * the zone of the trainer.
     */
    @ManyToOne
    @NotNull
    private Zone zone;

    /**
     * 
     */
    @OneToMany(cascade = { CascadeType.ALL })
    @Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
    @Sort(type = SortType.NATURAL)
    private SortedSet<TrainedSkill> trainedSkills = new TreeSet<TrainedSkill>();

    /**
     * getter for the id property.
     * 
     * @return the id.
     */
    public Integer getId() {
        return this.id;
    }

    /**
     * setter for the id property.
     * 
     * @param id the id to set.
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * getter for the trainedSkills property.
     * 
     * @return the trainedSkills.
     */
    public SortedSet<TrainedSkill> getTrainedSkills() {
        return this.trainedSkills;
    }

    /**
     * setter for the trainedSkills property.
     * 
     * @param trainedSkills the trainedSkills to set.
     */
    public void setTrainedSkills(SortedSet<TrainedSkill> trainedSkills) {
        this.trainedSkills = trainedSkills;
    }

    /**
     * {@inheritDoc}
     */
    public String getName() {
        return this.name;
    }

    /**
     * {@inheritDoc}
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * getter for the zone property.
     * 
     * @return the zone.
     */
    public Zone getZone() {
        return this.zone;
    }

    /**
     * setter for the zone property.
     * 
     * @param zone the zone to set.
     */
    public void setZone(Zone zone) {
        this.zone = zone;
    }

}
