1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.extras.controls.syncrepl.syncState;
21
22
23 import java.util.Arrays;
24
25 import org.apache.directory.api.ldap.model.message.Control;
26 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
27 import org.apache.directory.api.util.Strings;
28
29
30
31
32
33
34
35
36 public class SyncStateValueImpl extends AbstractControl implements SyncStateValue
37 {
38
39 private SyncStateTypeEnum type;
40
41
42 private byte[] cookie;
43
44
45 private byte[] entryUuid;
46
47
48
49
50
51 public SyncStateValueImpl()
52 {
53 super( OID );
54 }
55
56
57
58
59
60
61
62
63 public SyncStateValueImpl( boolean isCritical )
64 {
65 super( OID, isCritical );
66 }
67
68
69
70
71
72 public byte[] getCookie()
73 {
74 return cookie;
75 }
76
77
78
79
80
81 public void setCookie( byte[] cookie )
82 {
83 this.cookie = cookie;
84 }
85
86
87
88
89
90 public SyncStateTypeEnum getSyncStateType()
91 {
92 return type;
93 }
94
95
96
97
98
99 public void setSyncStateType( SyncStateTypeEnum syncStateType )
100 {
101 this.type = syncStateType;
102 }
103
104
105
106
107
108 public byte[] getEntryUUID()
109 {
110 return entryUuid;
111 }
112
113
114
115
116
117 public void setEntryUUID( byte[] entryUUID )
118 {
119 this.entryUuid = entryUUID;
120 }
121
122
123
124
125
126 @Override
127 public int hashCode()
128 {
129 int h = 37;
130
131 h = h * 17 + super.hashCode();
132 h = h * 17 + type.getValue();
133
134 if ( cookie != null )
135 {
136 for ( byte b : cookie )
137 {
138 h = h * 17 + b;
139 }
140 }
141
142 if ( entryUuid != null )
143 {
144 for ( byte b : entryUuid )
145 {
146 h = h * 17 + b;
147 }
148 }
149
150 return h;
151 }
152
153
154
155
156
157 @Override
158 public boolean equals( Object o )
159 {
160 if ( !super.equals( o ) )
161 {
162 return false;
163 }
164
165 if ( !( o instanceof SyncStateValue ) )
166 {
167 return false;
168 }
169
170 SyncStateValue otherControl = ( SyncStateValue ) o;
171
172 return ( type == otherControl.getSyncStateType() ) &&
173 ( Arrays.equals( entryUuid, otherControl.getEntryUUID() ) ) &&
174 ( Arrays.equals( cookie, otherControl.getCookie() ) &&
175 ( isCritical() == otherControl.isCritical() ) );
176 }
177
178
179
180
181
182 @Override
183 public String toString()
184 {
185 StringBuilder sb = new StringBuilder();
186
187 sb.append( " SyncStateValue control :\n" );
188 sb.append( " oid : " ).append( getOid() ).append( '\n' );
189 sb.append( " critical : " ).append( isCritical() ).append( '\n' );
190 sb.append( " syncStateType : '" ).append( getSyncStateType() ).append( "'\n" );
191 sb.append( " entryUUID : '" ).append( Strings.dumpBytes( getEntryUUID() ) ).append( "'\n" );
192 sb.append( " cookie : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
193
194 return sb.toString();
195 }
196 }