|
| 1 | +package software.xdev.vaadin.model; |
| 2 | + |
| 3 | +import java.time.LocalDate; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.List; |
| 6 | + |
| 7 | + |
| 8 | +/** |
| 9 | + * Represents a person with attributes such as first name, last name, birthday, subscription status, and an identifier. |
| 10 | + */ |
| 11 | +public class Person |
| 12 | +{ |
| 13 | + private Integer id; |
| 14 | + private String firstName; |
| 15 | + private String lastName; |
| 16 | + private LocalDate birthday; |
| 17 | + private boolean married; |
| 18 | + private double salary; |
| 19 | + private Department department; |
| 20 | + |
| 21 | + /** |
| 22 | + * Constructs a new instance of the Person class with the provided attributes. |
| 23 | + * |
| 24 | + * @param id The unique identifier of the person. |
| 25 | + * @param firstName The first name of the person. |
| 26 | + * @param lastName The last name of the person. |
| 27 | + * @param birthday The birthdate of the person. |
| 28 | + * @param married Whether the person is a married (true) or not (false). |
| 29 | + * @param salary The paid salary |
| 30 | + * @param department The associated department |
| 31 | + */ |
| 32 | + public Person( |
| 33 | + final Integer id, |
| 34 | + final String firstName, |
| 35 | + final String lastName, |
| 36 | + final LocalDate birthday, |
| 37 | + final boolean married, |
| 38 | + final double salary, |
| 39 | + final Department department) |
| 40 | + { |
| 41 | + this.id = id; |
| 42 | + this.firstName = firstName; |
| 43 | + this.lastName = lastName; |
| 44 | + this.birthday = birthday; |
| 45 | + this.married = married; |
| 46 | + this.salary = salary; |
| 47 | + this.department = department; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Gets the first name of the person. |
| 52 | + * |
| 53 | + * @return The first name of the person. |
| 54 | + */ |
| 55 | + public String getFirstName() |
| 56 | + { |
| 57 | + return this.firstName; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Sets the first name of the person. |
| 62 | + * |
| 63 | + * @param firstName The new first name to set. |
| 64 | + */ |
| 65 | + public void setFirstName(final String firstName) |
| 66 | + { |
| 67 | + this.firstName = firstName; |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Gets the last name of the person. |
| 72 | + * |
| 73 | + * @return The last name of the person. |
| 74 | + */ |
| 75 | + public String getLastName() |
| 76 | + { |
| 77 | + return this.lastName; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Sets the last name of the person. |
| 82 | + * |
| 83 | + * @param lastName The new last name to set. |
| 84 | + */ |
| 85 | + public void setLastName(final String lastName) |
| 86 | + { |
| 87 | + this.lastName = lastName; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Gets the birthdate of the person. |
| 92 | + * |
| 93 | + * @return The birthdate of the person. |
| 94 | + */ |
| 95 | + public LocalDate getBirthday() |
| 96 | + { |
| 97 | + return this.birthday; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Sets the birthdate of the person. |
| 102 | + * |
| 103 | + * @param birthday The new birthdate to set. |
| 104 | + */ |
| 105 | + public void setBirthday(final LocalDate birthday) |
| 106 | + { |
| 107 | + this.birthday = birthday; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Gets the unique identifier of the person. |
| 112 | + * |
| 113 | + * @return The unique identifier of the person. |
| 114 | + */ |
| 115 | + public Integer getId() |
| 116 | + { |
| 117 | + return this.id; |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * Sets the unique identifier of the person. |
| 122 | + * |
| 123 | + * @param id The new unique identifier to set. |
| 124 | + */ |
| 125 | + public void setId(final Integer id) |
| 126 | + { |
| 127 | + this.id = id; |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Checks if the person is married. |
| 132 | + * |
| 133 | + * @return True if the person is married, false otherwise. |
| 134 | + */ |
| 135 | + public boolean isMarried() |
| 136 | + { |
| 137 | + return this.married; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Sets person's married status. |
| 142 | + * |
| 143 | + * @param married True to mark the person as married, false to mark the person as unmarried. |
| 144 | + */ |
| 145 | + public void setMarried(final boolean married) |
| 146 | + { |
| 147 | + this.married = married; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | + * Gets the salary of the person. |
| 152 | + * |
| 153 | + * @return The salary of the person. |
| 154 | + */ |
| 155 | + |
| 156 | + public double getSalary() |
| 157 | + { |
| 158 | + return this.salary; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * Sets the salary of the person. |
| 163 | + * |
| 164 | + * @param salary The new salary to set. |
| 165 | + */ |
| 166 | + public void setSalary(final double salary) |
| 167 | + { |
| 168 | + this.salary = salary; |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Gets the associated department of the person. |
| 173 | + * |
| 174 | + * @return The associated department of the person. |
| 175 | + */ |
| 176 | + public Department getDepartment() |
| 177 | + { |
| 178 | + return this.department; |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * Sets the associated department of the person. |
| 183 | + * |
| 184 | + * @param department The associated department to set. |
| 185 | + */ |
| 186 | + public void setDepartment(final Department department) |
| 187 | + { |
| 188 | + this.department = department; |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * Retrieves a list of sample Person objects. |
| 193 | + * |
| 194 | + * @return A List containing sample Person objects. |
| 195 | + */ |
| 196 | + @SuppressWarnings("checkstyle:MagicNumber") |
| 197 | + public static List<Person> getPersons() |
| 198 | + { |
| 199 | + final List<Person> lst = new ArrayList<>(); |
| 200 | + |
| 201 | + lst.add(new Person(0, "Siegbert", "Schmidt", LocalDate.of(1990, 12, 17), false, 1000, Department.HR)); |
| 202 | + lst.add(new Person(1, "Herbert", "Maier", LocalDate.of(1967, 10, 13), false, 1000, Department.HR)); |
| 203 | + lst.add(new Person(2, "Hans", "Lang", LocalDate.of(2002, 5, 9), true, 9050.60, Department.HR)); |
| 204 | + lst.add(new Person(3, "Anton", "Meier", LocalDate.of(1985, 1, 24), true, 8000.75, Department.HR)); |
| 205 | + lst.add(new Person(4, "Sarah", "Smith", LocalDate.of(1999, 6, 1), false, 5000, Department.IT)); |
| 206 | + lst.add(new Person(5, "Niklas", "Sommer", LocalDate.of(1994, 11, 8), true, 4000.33, Department.HR)); |
| 207 | + lst.add(new Person(6, "Hanna", "Neubaum", LocalDate.of(1986, 8, 15), true, 3000, Department.HR)); |
| 208 | + lst.add(new Person(8, "Laura", "Fels", LocalDate.of(1996, 3, 20), true, 1000.50, Department.HR)); |
| 209 | + lst.add(new Person(7, "Sofia", "Sommer", LocalDate.of(1972, 4, 14), false, 2000, Department.ACCOUNTING)); |
| 210 | + |
| 211 | + return lst; |
| 212 | + } |
| 213 | +} |
0 commit comments