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.syncDone;
21
22
23 import java.util.Arrays;
24
25 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
26 import org.apache.directory.api.util.Strings;
27
28
29
30
31
32
33
34
35 public class SyncDoneValueImpl extends AbstractControl implements SyncDoneValue
36 {
37
38 private byte[] cookie;
39
40
41 private boolean refreshDeletes;
42
43
44
45
46
47 public SyncDoneValueImpl()
48 {
49 super( OID );
50 }
51
52
53
54
55
56
57
58
59 public SyncDoneValueImpl( boolean isCritical )
60 {
61 super( OID, isCritical );
62 }
63
64
65
66
67
68 public byte[] getCookie()
69 {
70 return cookie;
71 }
72
73
74
75
76
77 public void setCookie( byte[] cookie )
78 {
79 this.cookie = cookie;
80 }
81
82
83
84
85
86 public boolean isRefreshDeletes()
87 {
88 return refreshDeletes;
89 }
90
91
92
93
94
95 public void setRefreshDeletes( boolean refreshDeletes )
96 {
97 this.refreshDeletes = refreshDeletes;
98 }
99
100
101
102
103
104 @Override
105 public int hashCode()
106 {
107 int h = 37;
108
109 h = h * 17 + super.hashCode();
110 h = h * 17 + ( refreshDeletes ? 1 : 0 );
111
112 if ( cookie != null )
113 {
114 for ( byte b : cookie )
115 {
116 h = h * 17 + b;
117 }
118 }
119
120 return h;
121 }
122
123
124
125
126
127 @Override
128 public boolean equals( Object o )
129 {
130 if ( this == o )
131 {
132 return true;
133 }
134
135 if ( !( o instanceof SyncDoneValue ) )
136 {
137 return false;
138 }
139
140 SyncDoneValue otherControl = ( SyncDoneValue ) o;
141
142 return ( refreshDeletes == otherControl.isRefreshDeletes() ) &&
143 ( Arrays.equals( cookie, otherControl.getCookie() ) &&
144 ( isCritical() == otherControl.isCritical() ) );
145 }
146
147
148
149
150
151 @Override
152 public String toString()
153 {
154 StringBuilder sb = new StringBuilder();
155
156 sb.append( " SyncDoneValue control :\n" );
157 sb.append( " oid : " ).append( getOid() ).append( '\n' );
158 sb.append( " critical : " ).append( isCritical() ).append( '\n' );
159 sb.append( " cookie : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
160 sb.append( " refreshDeletes : '" ).append( isRefreshDeletes() ).append( "'\n" );
161
162 return sb.toString();
163 }
164 }