Skip to contentPackage: PersonEntity
PersonEntity
Coverage
1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2024 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
22: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.thesefoolishthings.examples.dci.persistable.jpa.role.impl;
27:
28: import javax.annotation.Nonnull;
29: import java.io.Serializable;
30: import jakarta.persistence.Column;
31: import jakarta.persistence.Entity;
32: import jakarta.persistence.Id;
33: import it.tidalwave.thesefoolishthings.examples.person.Person;
34: import lombok.Getter;
35: import lombok.NoArgsConstructor;
36: import lombok.Setter;
37: import lombok.ToString;
38:
39: /***************************************************************************************************************************************************************
40: *
41: * @author Fabrizio Giudici
42: *
43: **************************************************************************************************************************************************************/
44: @Entity @NoArgsConstructor @Getter @Setter @ToString
45: public class PersonEntity implements Serializable
46: {
47: @Id
48: private String id;
49:
50: @Column
51: private String firstName;
52:
53: @Column
54: private String lastName;
55:
56: public PersonEntity (@Nonnull final Person datum)
57: {
58: this.id = datum.getId().stringValue();
59: this.firstName = datum.getFirstName();
60: this.lastName = datum.getLastName();
61: }
62:
63: @Nonnull
64: public Person toPerson()
65: {
66: return new Person(new it.tidalwave.util.Id(id), firstName, lastName);
67: }
68: }