All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.novatec.testit.livingdoc.samples.application.phonebook.PhoneBook Maven / Gradle / Ivy

package info.novatec.testit.livingdoc.samples.application.phonebook;

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

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "PHONEBOOK")
@SuppressWarnings("serial")
public class PhoneBook extends AbstractEntity {
    private List entries = new ArrayList();
    private String name;

    public PhoneBook(String name) {
        super();

        this.name = name;
    }

    @Basic
    @Column(name = "NAME", unique = true, nullable = false, length = 255)
    public String getName() {
        return name;
    }

    @OneToMany(mappedBy = "phoneBook", cascade = CascadeType.ALL)
    public List getEntries() {
        return entries;
    }

    public void setEntries(List entries) {
        this.entries = entries;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void insert(String firstName, String lastName, String number) {
        entries.add(new PhoneBookEntry(this, firstName, lastName, number));
    }

    @Override
    public boolean equals(Object o) {
        if ( ! ( o instanceof PhoneBook )) {
            return false;
        }

        PhoneBook phoneBookCompared = ( PhoneBook ) o;

        return getName().equals(phoneBookCompared.getName());
    }

    @Override
    public int hashCode() {
        return getName().hashCode();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy