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

com.greenpepper.samples.application.phonebook.PhoneBook Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
package com.greenpepper.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
/**
 * 

PhoneBook class.

* * @author oaouattara * @version $Id: $Id */ @Table(name="PHONEBOOK") @SuppressWarnings("serial") public class PhoneBook extends AbstractEntity { private List entries = new ArrayList(); private String name; /** *

Constructor for PhoneBook.

* * @param name a {@link java.lang.String} object. */ public PhoneBook(String name) { super(); this.name = name; } /** *

Getter for the field name.

* * @return a {@link java.lang.String} object. */ @Basic @Column(name = "NAME", unique = true, nullable = false, length=255) public String getName() { return name; } /** *

Getter for the field entries.

* * @return a {@link java.util.List} object. */ @OneToMany(mappedBy="phoneBook", cascade=CascadeType.ALL) public List getEntries() { return entries; } /** *

Setter for the field entries.

* * @param entries a {@link java.util.List} object. */ public void setEntries(List entries) { this.entries = entries; } /** *

Setter for the field name.

* * @param name a {@link java.lang.String} object. */ public void setName(String name) { this.name = name; } /** *

insert.

* * @param firstName a {@link java.lang.String} object. * @param lastName a {@link java.lang.String} object. * @param number a {@link java.lang.String} object. */ public void insert(String firstName, String lastName, String number) { entries.add(new PhoneBookEntry(this, firstName, lastName, number)); } /** {@inheritDoc} */ public boolean equals(Object o) { if(!(o instanceof PhoneBook)) { return false; } PhoneBook phoneBookCompared = (PhoneBook)o; if(getName().equals(phoneBookCompared.getName())) { return true; } return false; } /** *

hashCode.

* * @return a int. */ public int hashCode() { return getName().hashCode(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy