View Javadoc
1   /*
2    * #%L
3    * Nuiton Validator
4    * %%
5    * Copyright (C) 2013 - 2014 Code Lutin, Tony Chemit
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
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   * TODO
31   *
32   * @author Tony Chemit - chemit@codelutin.com
33   * @since 2.0
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  }