JAVA-2116: Split or move libraries-data-2 module (#9716)
* JAVA-2116: Move Java-R Integration to libraries-6 module * JAVA-2116: Move Guide to JMapper to libraries-data module
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.baeldung.jmapper;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
public class User {
|
||||
|
||||
private long id;
|
||||
private String email;
|
||||
private LocalDate birthDate;
|
||||
|
||||
// constructors
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(long id, String email, LocalDate birthDate) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.email = email;
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [id=" + id + ", email=" + email + ", birthDate=" + birthDate + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.baeldung.jmapper;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JMap;
|
||||
import com.googlecode.jmapper.annotations.JMapConversion;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
|
||||
public class UserDto {
|
||||
|
||||
@JMap
|
||||
private long id;
|
||||
|
||||
@JMap("email")
|
||||
private String username;
|
||||
|
||||
@JMap("birthDate")
|
||||
private int age;
|
||||
|
||||
@JMapConversion(from={"birthDate"}, to={"age"})
|
||||
public int conversion(LocalDate birthDate){
|
||||
return Period.between(birthDate, LocalDate.now()).getYears();
|
||||
}
|
||||
|
||||
// constructors
|
||||
|
||||
public UserDto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserDto(long id, String username, int age) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDto [id=" + id + ", username=" + username + ", age=" + age + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.baeldung.jmapper;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
@JGlobalMap
|
||||
public class UserDto1 {
|
||||
|
||||
private long id;
|
||||
private String email;
|
||||
|
||||
|
||||
// constructors
|
||||
|
||||
public UserDto1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserDto1(long id, String email) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDto [id=" + id + ", email=" + email + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.baeldung.jmapper.relational;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JMap;
|
||||
|
||||
|
||||
public class User {
|
||||
|
||||
@JMap(classes = {UserDto1.class, UserDto2.class})
|
||||
private long id;
|
||||
|
||||
@JMap(attributes = {"username", "email"}, classes = {UserDto1.class, UserDto2.class})
|
||||
private String email;
|
||||
|
||||
// constructors
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(long id, String email) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [id=" + id + ", email=" + email + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.jmapper.relational;
|
||||
|
||||
|
||||
public class UserDto1 {
|
||||
|
||||
private long id;
|
||||
private String username;
|
||||
|
||||
// constructors
|
||||
|
||||
public UserDto1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserDto1(long id, String username) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDto [id=" + id + ", username=" + username + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.jmapper.relational;
|
||||
|
||||
|
||||
public class UserDto2 {
|
||||
|
||||
private long id;
|
||||
private String email;
|
||||
|
||||
// constructors
|
||||
|
||||
public UserDto2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserDto2(long id, String email) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDto2 [id=" + id + ", email=" + email + "]";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user