Apereo-Learning-Analytics-Initiative /
OpenLRW
| 1 | package unicon.matthews.oneroster.service.repository; |
||
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import org.apache.commons.lang3.builder.ToStringBuilder; |
||
| 6 | import org.apache.commons.lang3.builder.ToStringStyle; |
||
| 7 | import org.springframework.data.annotation.Id; |
||
| 8 | import org.springframework.data.mongodb.core.mapping.Document; |
||
| 9 | |||
| 10 | import unicon.matthews.oneroster.User; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @author ggilbert |
||
| 14 | * @author xchopin <[email protected]> |
||
| 15 | * |
||
| 16 | */ |
||
| 17 | @Document |
||
| 18 | public class MongoUser implements Serializable { |
||
| 19 | private static final long serialVersionUID = 1L; |
||
| 20 | |||
| 21 | @Id private String id; |
||
| 22 | private String orgId; |
||
| 23 | private String tenantId; |
||
| 24 | private User user; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 25 | |||
| 26 | private MongoUser() {} |
||
| 27 | |||
| 28 | public String getId() { |
||
| 29 | return id; |
||
| 30 | } |
||
| 31 | |||
| 32 | public String getOrgId() { |
||
| 33 | return orgId; |
||
| 34 | } |
||
| 35 | |||
| 36 | public String getTenantId() { |
||
| 37 | return tenantId; |
||
| 38 | } |
||
| 39 | |||
| 40 | public User getUser() { |
||
| 41 | return user; |
||
| 42 | } |
||
| 43 | |||
| 44 | @Override |
||
| 45 | public String toString() { |
||
| 46 | return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); |
||
| 47 | } |
||
| 48 | |||
| 49 | @Override |
||
| 50 | public int hashCode() { |
||
| 51 | final int prime = 31; |
||
| 52 | int result = 1; |
||
| 53 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
||
| 54 | result = prime * result + ((orgId == null) ? 0 : orgId.hashCode()); |
||
| 55 | result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); |
||
| 56 | result = prime * result + ((user == null) ? 0 : user.hashCode()); |
||
| 57 | return result; |
||
| 58 | } |
||
| 59 | |||
| 60 | @Override |
||
| 61 | public boolean equals(Object obj) { |
||
| 62 | if (this == obj) |
||
| 63 | return true; |
||
| 64 | if (obj == null) |
||
| 65 | return false; |
||
| 66 | if (getClass() != obj.getClass()) |
||
| 67 | return false; |
||
| 68 | MongoUser other = (MongoUser) obj; |
||
| 69 | if (id == null) { |
||
| 70 | if (other.id != null) |
||
| 71 | return false; |
||
| 72 | } else if (!id.equals(other.id)) |
||
| 73 | return false; |
||
| 74 | if (orgId == null) { |
||
| 75 | if (other.orgId != null) |
||
| 76 | return false; |
||
| 77 | } else if (!orgId.equals(other.orgId)) |
||
| 78 | return false; |
||
| 79 | if (tenantId == null) { |
||
| 80 | if (other.tenantId != null) |
||
| 81 | return false; |
||
| 82 | } else if (!tenantId.equals(other.tenantId)) |
||
| 83 | return false; |
||
| 84 | if (user == null) { |
||
| 85 | if (other.user != null) |
||
| 86 | return false; |
||
| 87 | } else if (!user.equals(other.user)) |
||
| 88 | return false; |
||
| 89 | return true; |
||
| 90 | } |
||
| 91 | |||
| 92 | public static class Builder { |
||
| 93 | private MongoUser _mongoUser = new MongoUser(); |
||
| 94 | |||
| 95 | public Builder withId(String id) { |
||
| 96 | this._mongoUser.id = id; |
||
| 97 | return this; |
||
| 98 | } |
||
| 99 | |||
| 100 | public Builder withOrgId(String orgId) { |
||
| 101 | this._mongoUser.orgId = orgId; |
||
| 102 | return this; |
||
| 103 | } |
||
| 104 | |||
| 105 | public Builder withTenantId(String tenantId) { |
||
| 106 | this._mongoUser.tenantId = tenantId; |
||
| 107 | return this; |
||
| 108 | } |
||
| 109 | |||
| 110 | public Builder withUser(User user) { |
||
| 111 | this._mongoUser.user = user; |
||
| 112 | return this; |
||
| 113 | } |
||
| 114 | |||
| 115 | public MongoUser build() { |
||
| 116 | return _mongoUser; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 |