Advertisement
Guest User

Untitled

a guest
Jan 25th, 2021
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package com.itstep.mvn.app.model;
  2.  
  3. public class Reader {
  4.  
  5. private int id;
  6. private String name;
  7.  
  8.  
  9. public Reader(int id, String name) {
  10. super();
  11. this.id = id;
  12. this.name = name;
  13. }
  14.  
  15. public int getId() {
  16. return id;
  17. }
  18.  
  19. public void setId(int id) {
  20. this.id = id;
  21. }
  22.  
  23. public String getName() {
  24. return name;
  25. }
  26.  
  27.  
  28.  
  29. public void setName(String name) {
  30. this.name = name;
  31. }
  32.  
  33.  
  34.  
  35. @Override
  36. public String toString() {
  37. return "Reader [id=" + id + ", name=" + name + "]";
  38. }
  39.  
  40. @Override
  41. public int hashCode() {
  42. final int prime = 31;
  43. int result = 1;
  44. result = prime * result + id;
  45. result = prime * result + ((name == null) ? 0 : name.hashCode());
  46. System.out.println("Reader -> hashCode() : " + result);
  47. return result;
  48. }
  49.  
  50. @Override
  51. public boolean equals(Object obj) {
  52. System.out.println("Reader -> equals()");
  53. if (this == obj)
  54. return true;
  55. if (obj == null)
  56. return false;
  57. if (getClass() != obj.getClass())
  58. return false;
  59. Reader other = (Reader) obj;
  60. if (id != other.id)
  61. return false;
  62. if (name == null) {
  63. if (other.name != null)
  64. return false;
  65. } else if (!name.equals(other.name))
  66. return false;
  67.  
  68. System.out.println(" TRUE");
  69. return true;
  70. }
  71.  
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement