package veilig.entry;

import java.net.URL;
import java.util.List;
import java.util.Vector;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity
public class Entry implements java.io.Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    private String name;

    private String username;

    private String email;

    //private URL url;
    private String url;

    private char[] password;

    @OneToMany(cascade=CascadeType.ALL)
    private List<AdditionalInformation> addInfo;

    /**
     * Constructor
     */
    public Entry() {
    }

    /**
     * 
     * @return id for this item
     */
    public Integer getId() {
        return id;
    }

    /**
     * Sets the id
     * @param id to be used
     */
    public void setId(Integer id) {
        this.id = id;
    }
    
    /**
     * Name
     * @return the name of the entry
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name of the Entry
     * @param name to be used
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Username related to the entry
     * @return username
     */
    public String getUsername() {
        return username;
    }

    /**
     * Username related to the entry
     * @param username to be used
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * The email address associated with this entry
     * @return email address
     */
    public String getEmail() {
        return email;
    }
    
    /**
     * Sets the email address for this Entry
     * @param email address for this entry
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * The url or web address for this Entry
     * @return url - web address
     */
    public String getUrl() {
        return url;
    }

    /**
     * Sets the url - web address for this Entry
     * @param url - web address
     */
    public void setUrl(String url) {
        this.url = url;
    }    
    
    /**
     * A list of any additional information about the entry
     * @return a List containing one or many addition information objects
     */
    public List<AdditionalInformation> getAddInfo() {
        return addInfo;
    }
    
    /**
     * Adds a List of AdditionalInformation Objects
     * @param ai Ovewrites the current list with the new one
     */
    public void setAddInfo(List<AdditionalInformation> ai) {
        this.addInfo = ai;
    }

    /**
     * Adds an object of AdditionalInformation to the list. 
     * @param ai Additionalinformation object to be added
     */
    public void addAdditInfo(AdditionalInformation ai) {
        if(addInfo == null) 
            addInfo = new Vector<AdditionalInformation>(0,1);
        addInfo.add(ai);
    }

    public char[] getPassword() {
        return password;
    }

    public void setPassword(char[] password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return this.name;
    }

    
}


