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

mybatis / hazelcast-cache / 374

03 May 2025 04:52AM CUT coverage: 46.154%. Remained the same
374

push

github

web-flow
Merge pull request #210 from mybatis/renovate/org.mybatis-mybatis-parent-49.x

Update dependency org.mybatis:mybatis-parent to v49

3 of 14 branches covered (21.43%)

24 of 52 relevant lines covered (46.15%)

0.46 hits per line

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

48.39
/src/main/java/org/mybatis/caches/hazelcast/AbstractHazelcastCache.java
1
/*
2
 *    Copyright 2010-2022 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.hazelcast;
17

18
import com.hazelcast.map.IMap;
19

20
import java.util.concurrent.locks.ReadWriteLock;
21

22
import org.apache.ibatis.cache.Cache;
23

24
/**
25
 * The Class AbstractHazelcastCache.
26
 */
27
public abstract class AbstractHazelcastCache implements Cache {
28

29
  /** The {@code ReadWriteLock}. */
30
  protected final ReadWriteLock readWriteLock = new DummyReadWriteLock();
1✔
31

32
  /** The cache id. */
33
  protected final String id;
34

35
  /** The cache map reference. */
36
  protected final IMap<Object, Object> cacheMap;
37

38
  /**
39
   * Instantiates a new abstract hazelcast cache.
40
   *
41
   * @param id
42
   *          the id
43
   * @param imap
44
   *          the i map
45
   */
46
  protected AbstractHazelcastCache(String id, IMap<Object, Object> imap) {
1✔
47
    if (id == null) {
1!
48
      throw new IllegalArgumentException("Cache instances require an id");
×
49
    }
50
    if (imap == null) {
1!
51
      throw new IllegalArgumentException("Cache instances require a cacheMap");
×
52
    }
53
    this.id = id;
1✔
54
    this.cacheMap = imap;
1✔
55
  }
1✔
56

57
  @Override
58
  public void clear() {
59
    this.cacheMap.clear();
1✔
60
  }
1✔
61

62
  @Override
63
  public String getId() {
64
    return this.id;
×
65
  }
66

67
  @Override
68
  public Object getObject(Object key) {
69
    return this.cacheMap.get(key);
1✔
70
  }
71

72
  @Override
73
  public ReadWriteLock getReadWriteLock() {
74
    return this.readWriteLock;
×
75
  }
76

77
  @Override
78
  public int getSize() {
79
    return this.cacheMap.size();
1✔
80
  }
81

82
  @Override
83
  public void putObject(Object key, Object value) {
84
    if (value != null) {
1!
85
      this.cacheMap.set(key, value);
1✔
86
    } else {
87
      if (this.cacheMap.containsKey(key)) {
×
88
        this.cacheMap.remove(key);
×
89
      }
90
    }
91
  }
1✔
92

93
  @Override
94
  public Object removeObject(Object key) {
95
    return this.cacheMap.remove(key);
1✔
96
  }
97

98
  @Override
99
  public boolean equals(Object obj) {
100
    if (this == obj) {
×
101
      return true;
×
102
    }
103
    if (obj == null) {
×
104
      return false;
×
105
    }
106
    if (!(obj instanceof Cache)) {
×
107
      return false;
×
108
    }
109

110
    Cache otherCache = (Cache) obj;
×
111
    return this.id.equals(otherCache.getId());
×
112
  }
113

114
  @Override
115
  public int hashCode() {
116
    return this.id.hashCode();
×
117
  }
118

119
  @Override
120
  public String toString() {
121
    return "Hazelcast {" + this.id + "}";
×
122
  }
123

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

© 2025 Coveralls, Inc