1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.socialsignin.spring.data.dynamodb.domain.sample;
17
18 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedDefault;
19 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
20 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
21 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexHashKey;
22 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexRangeKey;
23 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMarshalling;
24 import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
25 import org.socialsignin.spring.data.dynamodb.marshaller.Instant2IsoDynamoDBMarshaller;
26
27 import java.time.Instant;
28 import java.util.Date;
29 import java.util.Set;
30
31 @DynamoDBTable(tableName = "user")
32 public class User {
33
34 private String id;
35
36 private String name;
37
38 private Integer numberOfPlaylists;
39
40 private Date joinDate;
41
42 @SuppressWarnings("deprecation")
43 @DynamoDBMarshalling(marshallerClass = DynamoDBYearMarshaller.class)
44 private Date joinYear;
45
46 private Instant leaveDate;
47
48 private String postCode;
49
50 private Set<String> testSet;
51
52 public Set<String> getTestSet() {
53 return testSet;
54 }
55
56 public void setTestSet(Set<String> testSet) {
57 this.testSet = testSet;
58 }
59
60 public Date getJoinDate() {
61 return joinDate;
62 }
63
64 public void setJoinDate(Date joinDate) {
65 this.joinDate = joinDate;
66 }
67
68 public Date getJoinYear() {
69 return joinYear;
70 }
71
72 public void setJoinYear(Date joinYear) {
73 this.joinYear = joinYear;
74 }
75
76 @SuppressWarnings("deprecation")
77 @DynamoDBMarshalling(marshallerClass = Instant2IsoDynamoDBMarshaller.class)
78 public Instant getLeaveDate() {
79 return leaveDate;
80 }
81
82 public void setLeaveDate(Instant leaveDate) {
83 this.leaveDate = leaveDate;
84 }
85
86 @DynamoDBIndexHashKey(globalSecondaryIndexName = "idx_postCode_numberOfPlaylist")
87 public String getPostCode() {
88 return postCode;
89 }
90
91 public void setPostCode(String postCode) {
92 this.postCode = postCode;
93 }
94
95 @DynamoDBHashKey(attributeName = "Id")
96 @DynamoDBAutoGeneratedKey
97 public String getId() {
98 return id;
99 }
100
101 public void setId(String id) {
102 this.id = id;
103 }
104
105 public String getName() {
106 return name;
107 }
108
109 public void setName(String name) {
110 this.name = name;
111 }
112
113 @DynamoDBIndexRangeKey(globalSecondaryIndexName = "idx_postCode_numberOfPlaylist")
114 public Integer getNumberOfPlaylists() {
115 return numberOfPlaylists;
116 }
117
118 public void setNumberOfPlaylists(Integer numberOfPlaylists) {
119 this.numberOfPlaylists = numberOfPlaylists;
120 }
121
122 @Override
123 public int hashCode() {
124 final int prime = 31;
125 int result = 1;
126 result = prime * result + ((id == null) ? 0 : id.hashCode());
127 result = prime * result + ((joinDate == null) ? 0 : joinDate.hashCode());
128 result = prime * result + ((joinYear == null) ? 0 : joinYear.hashCode());
129 result = prime * result + ((leaveDate == null) ? 0 : leaveDate.hashCode());
130 result = prime * result + ((name == null) ? 0 : name.hashCode());
131 result = prime * result + ((numberOfPlaylists == null) ? 0 : numberOfPlaylists.hashCode());
132 result = prime * result + ((postCode == null) ? 0 : postCode.hashCode());
133 result = prime * result + ((testSet == null) ? 0 : testSet.hashCode());
134 return result;
135 }
136
137 @Override
138 public boolean equals(Object obj) {
139 if (this == obj)
140 return true;
141 if (obj == null)
142 return false;
143 if (getClass() != obj.getClass())
144 return false;
145 User other = (User) obj;
146 if (id == null) {
147 if (other.id != null)
148 return false;
149 } else if (!id.equals(other.id))
150 return false;
151 if (joinDate == null) {
152 if (other.joinDate != null)
153 return false;
154 } else if (!joinDate.equals(other.joinDate))
155 return false;
156 if (joinYear == null) {
157 if (other.joinYear != null)
158 return false;
159 } else if (!joinYear.equals(other.joinYear))
160 if (leaveDate == null) {
161 if (other.leaveDate != null)
162 return false;
163 } else if (!leaveDate.equals(other.leaveDate))
164 return false;
165 if (name == null) {
166 if (other.name != null)
167 return false;
168 } else if (!name.equals(other.name))
169 return false;
170 if (numberOfPlaylists == null) {
171 if (other.numberOfPlaylists != null)
172 return false;
173 } else if (!numberOfPlaylists.equals(other.numberOfPlaylists))
174 return false;
175 if (postCode == null) {
176 if (other.postCode != null)
177 return false;
178 } else if (!postCode.equals(other.postCode))
179 return false;
180 if (testSet == null) {
181 if (other.testSet != null)
182 return false;
183 } else if (!testSet.equals(other.testSet))
184 return false;
185 return true;
186 }
187
188 }