• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / memcached-cache / 483

20 Jul 2026 01:17AM UTC coverage: 81.217% (+21.4%) from 59.788%
483

push

github

hazendaz
Update test for sha-256 test

87 of 136 branches covered (63.97%)

307 of 378 relevant lines covered (81.22%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.15
/src/main/java/org/mybatis/caches/memcached/MemcachedConfiguration.java
1
/*
2
 *    Copyright 2012-2026 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.caches.memcached;
17

18
import java.net.InetSocketAddress;
19
import java.util.List;
20
import java.util.concurrent.TimeUnit;
21

22
import net.spy.memcached.ConnectionFactory;
23

24
/**
25
 * The Memcached client configuration.
26
 *
27
 * @author Simone Tripodi
28
 */
29
final class MemcachedConfiguration {
1✔
30

31
  /**
32
   * The key prefix.
33
   */
34
  private String keyPrefix;
35

36
  /**
37
   * The Connection Factory used to establish the connection to Memcached server(s).
38
   */
39
  private ConnectionFactory connectionFactory;
40

41
  /**
42
   * The Memcached servers.
43
   */
44
  private List<InetSocketAddress> addresses;
45

46
  /**
47
   * The flag to switch from sync to async Memcached get.
48
   */
49
  private boolean usingAsyncGet;
50

51
  /**
52
   * Compression enabled flag.
53
   */
54
  private boolean compressionEnabled;
55

56
  /**
57
   * The Memcached entries expiration time.
58
   */
59
  private int expiration;
60

61
  /**
62
   * The Memcached connection timeout when using async get.
63
   */
64
  private int timeout;
65

66
  /**
67
   * The Memcached timeout unit when using async get.
68
   */
69
  private TimeUnit timeUnit;
70

71
  /**
72
   * The flag to enable SASL Connection
73
   */
74
  private boolean usingSASL;
75

76
  /**
77
   * The Memcached SASL username
78
   */
79
  private String username;
80

81
  /**
82
   * The Memcached SASL password
83
   */
84
  private String password;
85

86
  /**
87
   * @return the keyPrefix
88
   */
89
  public String getKeyPrefix() {
90
    return keyPrefix;
1✔
91
  }
92

93
  /**
94
   * @param keyPrefix
95
   *          the keyPrefix to set
96
   */
97
  public void setKeyPrefix(String keyPrefix) {
98
    this.keyPrefix = keyPrefix;
1✔
99
  }
1✔
100

101
  /**
102
   * @return the connectionFactory
103
   */
104
  public ConnectionFactory getConnectionFactory() {
105
    return connectionFactory;
1✔
106
  }
107

108
  /**
109
   * @param connectionFactory
110
   *          the connectionFactory to set
111
   */
112
  public void setConnectionFactory(ConnectionFactory connectionFactory) {
113
    this.connectionFactory = connectionFactory;
1✔
114
  }
1✔
115

116
  /**
117
   * @return the addresses
118
   */
119
  public List<InetSocketAddress> getAddresses() {
120
    return addresses;
1✔
121
  }
122

123
  /**
124
   * @param addresses
125
   *          the addresses to set
126
   */
127
  public void setAddresses(List<InetSocketAddress> addresses) {
128
    this.addresses = addresses;
1✔
129
  }
1✔
130

131
  /**
132
   * @return the usingAsyncGet
133
   */
134
  public boolean isUsingAsyncGet() {
135
    return usingAsyncGet;
1✔
136
  }
137

138
  /**
139
   * @param usingAsyncGet
140
   *          the usingAsyncGet to set
141
   */
142
  public void setUsingAsyncGet(boolean usingAsyncGet) {
143
    this.usingAsyncGet = usingAsyncGet;
1✔
144
  }
1✔
145

146
  /**
147
   * @return the compressionEnabled
148
   */
149
  public boolean isCompressionEnabled() {
150
    return compressionEnabled;
1✔
151
  }
152

153
  /**
154
   * @param compressionEnabled
155
   *          the compressionEnabled to set
156
   */
157
  public void setCompressionEnabled(boolean compressionEnabled) {
158
    this.compressionEnabled = compressionEnabled;
1✔
159
  }
1✔
160

161
  /**
162
   * @return the expiration
163
   */
164
  public int getExpiration() {
165
    return expiration;
1✔
166
  }
167

168
  /**
169
   * @param expiration
170
   *          the expiration to set
171
   */
172
  public void setExpiration(int expiration) {
173
    this.expiration = expiration;
1✔
174
  }
1✔
175

176
  /**
177
   * @return the timeout
178
   */
179
  public int getTimeout() {
180
    return timeout;
1✔
181
  }
182

183
  /**
184
   * @param timeout
185
   *          the timeout to set
186
   */
187
  public void setTimeout(int timeout) {
188
    this.timeout = timeout;
1✔
189
  }
1✔
190

191
  /**
192
   * @return the timeUnit
193
   */
194
  public TimeUnit getTimeUnit() {
195
    return timeUnit;
1✔
196
  }
197

198
  /**
199
   * @param timeUnit
200
   *          the timeUnit to set
201
   */
202
  public void setTimeUnit(TimeUnit timeUnit) {
203
    this.timeUnit = timeUnit;
1✔
204
  }
1✔
205

206
  /**
207
   * @return the usingSASL
208
   */
209
  public boolean isUsingSASL() {
210
    return usingSASL;
1✔
211
  }
212

213
  /**
214
   * @param usingSASL
215
   *          the usingSASL to set
216
   */
217
  public void setUsingSASL(boolean usingSASL) {
218
    this.usingSASL = usingSASL;
1✔
219
  }
1✔
220

221
  /**
222
   * @return the username
223
   */
224
  public String getUsername() {
225
    return username;
1✔
226
  }
227

228
  /**
229
   * @param username
230
   *          the username to set
231
   */
232
  public void setUsername(String username) {
233
    this.username = username;
1✔
234
  }
1✔
235

236
  /**
237
   * @return the password
238
   */
239
  public String getPassword() {
240
    return password;
1✔
241
  }
242

243
  /**
244
   * @param password
245
   *          the password to set
246
   */
247
  public void setPassword(String password) {
248
    this.password = password;
1✔
249
  }
1✔
250

251
  /**
252
   * {@inheritDoc}
253
   */
254
  @Override
255
  public int hashCode() {
256
    return hash(1, 31, addresses, compressionEnabled, connectionFactory, expiration, keyPrefix, timeUnit, timeout,
1✔
257
        usingAsyncGet, usingSASL, username, password);
1✔
258
  }
259

260
  /**
261
   * Computes a hashCode given the input objects.
262
   *
263
   * @param initialNonZeroOddNumber
264
   *          a non-zero, odd number used as the initial value.
265
   * @param multiplierNonZeroOddNumber
266
   *          a non-zero, odd number used as the multiplier.
267
   * @param objs
268
   *          the objects to compute hash code.
269
   *
270
   * @return the computed hashCode.
271
   */
272
  public static int hash(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object... objs) {
273
    int result = initialNonZeroOddNumber;
1✔
274
    for (Object obj : objs) {
1✔
275
      result = multiplierNonZeroOddNumber * result + (obj != null ? obj.hashCode() : 0);
1✔
276
    }
277
    return result;
1✔
278
  }
279

280
  /**
281
   * {@inheritDoc}
282
   */
283
  @Override
284
  public boolean equals(Object obj) {
285
    if (this == obj) {
1!
286
      return true;
×
287
    }
288
    if (obj == null || getClass() != obj.getClass()) {
1✔
289
      return false;
1✔
290
    }
291

292
    MemcachedConfiguration other = (MemcachedConfiguration) obj;
1✔
293
    return eq(addresses, other.addresses) && eq(compressionEnabled, other.compressionEnabled)
1!
294
        && eq(connectionFactory, other.connectionFactory) && eq(expiration, other.expiration)
1!
295
        && eq(keyPrefix, other.keyPrefix) && eq(timeUnit, other.timeUnit) && eq(timeout, other.timeout)
1!
296
        && eq(usingAsyncGet, other.usingAsyncGet) && eq(usingSASL, other.usingSASL) && eq(username, other.username)
1!
297
        && eq(password, other.password);
1!
298
  }
299

300
  /**
301
   * Verifies input objects are equal.
302
   *
303
   * @param o1
304
   *          the first argument to compare
305
   * @param o2
306
   *          the second argument to compare
307
   *
308
   * @return true, if the input arguments are equal, false otherwise.
309
   */
310
  private static <O> boolean eq(O o1, O o2) {
311
    return o1 != null ? o1.equals(o2) : o2 == null;
1!
312
  }
313

314
  /**
315
   * {@inheritDoc}
316
   */
317
  @Override
318
  public String toString() {
319
    return "MemcachedConfiguration [addresses=%s, compressionEnabled=%s, connectionFactory=%s, , expiration=%s, keyPrefix=%s, timeUnit=%s, timeout=%s, usingAsyncGet=%s, usingSASL=%s, username=%s, password=%s]"
1✔
320
        .formatted(addresses, compressionEnabled, connectionFactory, expiration, keyPrefix, timeUnit, timeout,
1✔
321
            usingAsyncGet, usingSASL, username, password);
1✔
322
  }
323

324
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc