1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
@Entity
@Table(name = "contact", schema = "public")
public class Contact implements java.io.Serializable {
private static final long serialVersionUID = 922930571126812834L;
private int nocontact;
private Clients clients;
private String nom;
private String prenom;
private String adresse;
private String fonction;
private String service;
private String telephones;
private String email1;
private String email2;
private String email3;
public Contact() {
}
public Contact(int nocontact, Clients clients) {
this.nocontact = nocontact;
this.clients = clients;
}
public Contact(int nocontact, Clients clients, String nom, String prenom,
String adresse, String fonction, String service, String telephones,
String email1, String email2, String email3) {
this.nocontact = nocontact;
this.clients = clients;
this.nom = nom;
this.prenom = prenom;
this.adresse = adresse;
this.fonction = fonction;
this.service = service;
this.telephones = telephones;
this.email1 = email1;
this.email2 = email2;
this.email3 = email3;
}
@Id
@SequenceGenerator(sequenceName = "contact_nocontact_seq", name = "contact_nocontact_seq")
@GeneratedValue(strategy = GenerationType.AUTO, generator="contact_nocontact_seq")
@Column(name = "nocontact", unique = true, nullable = false)
public int getNocontact() {
return this.nocontact;
}
public void setNocontact(int nocontact) {
this.nocontact = nocontact;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "identrepriseclient", nullable = false)
public Clients getClients() {
return this.clients;
}
public void setClients(Clients clients) {
this.clients = clients;
}
@Column(name = "nom", length = 32)
public String getNom() {
return this.nom;
}
public void setNom(String nom) {
this.nom = nom;
}
@Column(name = "prenom", length = 32)
public String getPrenom() {
return this.prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
@Column(name = "adresse", length = 256)
public String getAdresse() {
return this.adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
@Column(name = "fonction", length = 32)
public String getFonction() {
return this.fonction;
}
public void setFonction(String fonction) {
this.fonction = fonction;
}
@Column(name = "service", length = 32)
public String getService() {
return this.service;
}
public void setService(String service) {
this.service = service;
}
@Column(name = "telephones", length = 64)
public String getTelephones() {
return this.telephones;
}
public void setTelephones(String telephones) {
this.telephones = telephones;
}
@Column(name = "email1", length = 256)
public String getEmail1() {
return this.email1;
}
public void setEmail1(String email1) {
this.email1 = email1;
}
@Column(name = "email2", length = 256)
public String getEmail2() {
return this.email2;
}
public void setEmail2(String email2) {
this.email2 = email2;
}
@Column(name = "email3", length = 256)
public String getEmail3() {
return this.email3;
}
public void setEmail3(String email3) {
this.email3 = email3;
}
/**
* teste l'égalité entre deux objet contact
* @param contact le contact à comparer
*/
@Override
public boolean equals(Object contact) {
if ( (this == contact ) ){
return true;
}
if ( !(contact instanceof Contact) ){
return false;
}
Contact contactACompare = (Contact) contact;
return this.nom.equals(contactACompare.nom)
&& this.prenom.equals(contactACompare.prenom)
&& this.clients.equals(contactACompare.clients);
}
/**
*
*/
@Override
public int hashCode() {
return new HashCodeBuilder().append(
this.nom + this.prenom + this.clients.getNom()).toHashCode();
}
/**
* compare deux objets dans le cas 'un tri. La comparation se fait sur le
* nom, le prénom et le nom de la société du contact
*
* @param contact
* le contact à comparer
* @return
*/
public int compareTo(Object contact) {
Contact contactACompare = (Contact) contact;
String chaineContact = this.nom + this.prenom + this.clients.getNom();
String chaineContactAComparer = contactACompare.nom
+ contactACompare.prenom + contactACompare.clients.getNom();
return chaineContact.compareTo(chaineContactAComparer);
}
} |
Partager