1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  package org.nuiton.validator.model;
23  
24  import org.apache.commons.lang3.builder.ToStringBuilder;
25  
26  import java.util.ArrayList;
27  import java.util.Collection;
28  
29  
30  
31  
32  
33  
34  
35  public class Person {
36  
37      public static final String PROPERTY_NAME = "name";
38  
39      public static final String PROPERTY_FIRSTNAME = "firstname";
40  
41      public static final String PROPERTY_PET = "pet";
42  
43      protected String name;
44  
45      protected String firstname;
46  
47      protected Collection<Pet> pet;
48  
49      public String getName() {
50          return name;
51      }
52  
53      public void setName(String name) {
54          this.name = name;
55      }
56  
57      public String getFirstname() {
58          return firstname;
59      }
60  
61      public void setFirstname(String firstname) {
62          this.firstname = firstname;
63      }
64  
65      public Collection<Pet> getPet() {
66          return pet;
67      }
68  
69      public void setPet(Collection<Pet> pet) {
70          this.pet = pet;
71      }
72  
73      public void addPet(Pet pet) {
74          if (this.pet == null) {
75              this.pet = new ArrayList<Pet>();
76          }
77  
78          pet.setPerson(this);
79  
80          this.pet.add(pet);
81      }
82  
83      @Override
84      public String toString() {
85          String result = new ToStringBuilder(this).
86                  append(PROPERTY_NAME, name).
87                  append(PROPERTY_FIRSTNAME, firstname).
88                  toString();
89          return result;
90      }
91  }