User

  1. import org.msgpack.annotation.Message;
  2. @Message
  3. public class User {
  4. private String id;
  5. private String userName;
  6. private int age;
  7. private UserContact userContact;
  8. public User(String userName, int age, String id) {
  9. this.userName = userName;
  10. this.age = age;
  11. this.id = id;
  12. }
  13. public User() {
  14. }
  15. public String getUserName() {
  16. return userName;
  17. }
  18. public void setUserName(String userName) {
  19. this.userName = userName;
  20. }
  21. public int getAge() {
  22. return age;
  23. }
  24. public void setAge(int age) {
  25. this.age = age;
  26. }
  27. public String getId() {
  28. return id;
  29. }
  30. public void setId(String id) {
  31. this.id = id;
  32. }
  33. public UserContact getUserContact() {
  34. return userContact;
  35. }
  36. public void setUserContact(UserContact userContact) {
  37. this.userContact = userContact;
  38. }
  39. @Override
  40. public String toString() {
  41. return "User{" +
  42. "userName='" + userName + '\'' +
  43. ", age=" + age +
  44. ", id='" + id + '\'' +
  45. ", userContact=" + userContact +
  46. '}';
  47. }
  48. }

UserContact

  1. import org.msgpack.annotation.Message;
  2. @Message//MessagePack提供的注解,表明这是一个需要序列化的实体类
  3. public class UserContact {
  4. private String mail;
  5. private String phone;
  6. public UserContact() {
  7. }
  8. public UserContact(String mail, String phone) {
  9. this.mail = mail;
  10. this.phone = phone;
  11. }
  12. public String getMail() {
  13. return mail;
  14. }
  15. public void setMail(String mail) {
  16. this.mail = mail;
  17. }
  18. public String getPhone() {
  19. return phone;
  20. }
  21. public void setPhone(String phone) {
  22. this.phone = phone;
  23. }
  24. @Override
  25. public String toString() {
  26. return "UserContact{" +
  27. "mail='" + mail + '\'' +
  28. ", phone='" + phone + '\'' +
  29. '}';
  30. }
  31. }