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

ben-manes / caffeine / #5173

29 Dec 2025 05:27AM UTC coverage: 0.0% (-100.0%) from 100.0%
#5173

push

github

ben-manes
speed up development ci build

0 of 3838 branches covered (0.0%)

0 of 7869 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java
1
/*
2
 * Copyright 2015 Ben Manes. All Rights Reserved.
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
 *     http://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 com.github.benmanes.caffeine.jcache.event;
17

18
import static java.util.Objects.requireNonNull;
19

20
import java.util.Iterator;
21
import java.util.NoSuchElementException;
22

23
import javax.cache.Cache;
24
import javax.cache.event.CacheEntryEvent;
25
import javax.cache.event.EventType;
26

27
import org.jspecify.annotations.Nullable;
28

29
/**
30
 * A cache event dispatched to a listener.
31
 *
32
 * @author ben.manes@gmail.com (Ben Manes)
33
 */
34
@SuppressWarnings("serial")
35
final class JCacheEntryEvent<K, V> extends CacheEntryEvent<K, V>
36
    implements Iterable<CacheEntryEvent<? extends K, ? extends V>> {
37
  private static final long serialVersionUID = 1L;
38

39
  private final K key;
40
  private final boolean hasOldValue;
41
  private final @Nullable V oldValue;
42
  private final @Nullable V newValue;
43

44
  JCacheEntryEvent(Cache<K, V> source, EventType eventType,
45
      K key, boolean hasOldValue, @Nullable V oldValue, @Nullable V newValue) {
46
    super(source, eventType);
×
47
    this.key = requireNonNull(key);
×
48
    this.hasOldValue = hasOldValue;
×
49
    this.oldValue = oldValue;
×
50
    this.newValue = newValue;
×
51
  }
×
52

53
  @Override
54
  public K getKey() {
55
    return key;
×
56
  }
57

58
  @Override
59
  public @Nullable V getValue() {
60
    return newValue;
×
61
  }
62

63
  @Override
64
  public @Nullable V getOldValue() {
65
    return oldValue;
×
66
  }
67

68
  @Override
69
  public boolean isOldValueAvailable() {
70
    return hasOldValue;
×
71
  }
72

73
  @Override
74
  public <T> T unwrap(Class<T> clazz) {
75
    if (!clazz.isInstance(this)) {
×
76
      throw new IllegalArgumentException("Class " + clazz + " is unknown to this implementation");
×
77
    }
78
    @SuppressWarnings("unchecked")
79
    var castedEntry = (T) this;
×
80
    return castedEntry;
×
81
  }
82

83
  @Override
84
  public Iterator<CacheEntryEvent<? extends K, ? extends V>> iterator() {
85
    return new Iterator<>() {
×
86
      boolean hasNext = true;
×
87

88
      @Override
89
      public boolean hasNext() {
90
        return hasNext;
×
91
      }
92

93
      @Override
94
      public CacheEntryEvent<K, V> next() {
95
        if (!hasNext()) {
×
96
          throw new NoSuchElementException();
×
97
        }
98
        hasNext = false;
×
99
        return JCacheEntryEvent.this;
×
100
      }
101
    };
102
  }
103
}
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

© 2026 Coveralls, Inc