15
15
*/
16
16
package org .springframework .data .couchbase .domain ;
17
17
18
- import lombok .Value ;
19
- import lombok .With ;
20
18
import org .springframework .data .annotation .Id ;
21
19
import org .springframework .data .annotation .Version ;
22
20
import org .springframework .data .couchbase .core .mapping .Document ;
30
28
* @author Michael Reiche
31
29
*/
32
30
33
- @ Value
34
31
@ Document
35
32
public class PersonValue {
36
33
@ Id @ GeneratedValue (strategy = GenerationStrategy .UNIQUE )
37
- @ With String id ;
38
- @ Version
39
- @ With
40
- long version ;
41
- @ Field String firstname ;
42
- @ Field String lastname ;
34
+ private final String id ;
35
+ @ Version private final long version ;
36
+ @ Field private final String firstname ;
37
+ @ Field private final String lastname ;
43
38
44
39
public PersonValue (String id , long version , String firstname , String lastname ) {
45
40
this .id = id ;
@@ -48,15 +43,56 @@ public PersonValue(String id, long version, String firstname, String lastname) {
48
43
this .lastname = lastname ;
49
44
}
50
45
46
+ public PersonValue withId (String id ) {
47
+ return new PersonValue (id , this .version , this .firstname , this .lastname );
48
+ }
49
+
50
+ public PersonValue withVersion (Long version ) {
51
+ return new PersonValue (this .id , version , this .firstname , this .lastname );
52
+ }
53
+
54
+ public PersonValue withFirstname (String firstname ) {
55
+ return new PersonValue (this .id , this .version , firstname , this .lastname );
56
+ }
57
+
58
+ public PersonValue withLastname (String lastname ) {
59
+ return new PersonValue (this .id , this .version , this .firstname , lastname );
60
+ }
61
+
51
62
public String toString () {
52
63
StringBuilder sb = new StringBuilder ();
53
64
sb .append ("PersonValue : {" );
54
- sb .append (" id : " + getId () );
65
+ sb .append (" id : " + id );
55
66
sb .append (", version : " + version );
56
67
sb .append (", firstname : " + firstname );
57
68
sb .append (", lastname : " + lastname );
58
69
sb .append (" }" );
59
70
return sb .toString ();
60
71
}
61
72
73
+ public String getId () {
74
+ return id ;
75
+ }
76
+
77
+ public long getVersion () {
78
+ return version ;
79
+ }
80
+
81
+ public boolean equals (Object other ) {
82
+ if (other == null || !(other instanceof PersonValue )) {
83
+ return false ;
84
+ }
85
+ PersonValue that = (PersonValue ) other ;
86
+ return equals (this .getId (), that .getId ()) && equals (this .version , that .version )
87
+ && equals (this .firstname , that .firstname ) && equals (this .lastname , that .lastname );
88
+ }
89
+
90
+ boolean equals (Object s0 , Object s1 ) {
91
+ if (s0 == null && s1 == null || s0 == s1 ) {
92
+ return true ;
93
+ }
94
+ Object sa = s0 != null ? s0 : s1 ;
95
+ Object sb = s0 != null ? s1 : s0 ;
96
+ return sa .equals (sb );
97
+ }
62
98
}
0 commit comments