• 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
/caffeine/src/main/java/com/github/benmanes/caffeine/cache/RemovalCause.java
1
/*
2
 * Copyright 2014 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.cache;
17

18
import org.jspecify.annotations.NullMarked;
19

20
/**
21
 * The reason why a cached entry was removed.
22
 *
23
 * @author ben.manes@gmail.com (Ben Manes)
24
 */
25
@NullMarked
×
26
public enum RemovalCause {
27

28
  /**
29
   * The entry was manually removed by the user. This can result from the user invoking any of the
30
   * following methods on the cache or map view.
31
   * <ul>
32
   *   <li>{@link Cache#invalidate}</li>
33
   *   <li>{@link Cache#invalidateAll(Iterable)}</li>
34
   *   <li>{@link Cache#invalidateAll()}</li>
35
   *   <li>{@link LoadingCache#refresh}</li>
36
   *   <li>{@link java.util.Map#remove}</li>
37
   *   <li>{@link java.util.Map#computeIfPresent}</li>
38
   *   <li>{@link java.util.Map#compute}</li>
39
   *   <li>{@link java.util.Map#merge}</li>
40
   *   <li>{@link java.util.concurrent.ConcurrentMap#remove}</li>
41
   * </ul>
42
   * A manual removal may also be performed through the key, value, or entry collections views by
43
   * the user invoking any of the following methods.
44
   * <ul>
45
   *   <li>{@link java.util.Collection#remove}</li>
46
   *   <li>{@link java.util.Collection#removeAll}</li>
47
   *   <li>{@link java.util.Collection#removeIf}</li>
48
   *   <li>{@link java.util.Collection#retainAll}</li>
49
   *   <li>{@link java.util.Iterator#remove}</li>
50
   * </ul>
51
   */
52
  EXPLICIT {
×
53
    @Override public boolean wasEvicted() {
54
      return false;
×
55
    }
56
  },
57

58
  /**
59
   * The entry itself was not actually removed, but its value was replaced by the user. This can
60
   * result from the user invoking any of the following methods on the cache or map view.
61
   * <ul>
62
   *   <li>{@link Cache#put}</li>
63
   *   <li>{@link Cache#putAll}</li>
64
   *   <li>{@link LoadingCache#getAll}</li>
65
   *   <li>{@link LoadingCache#refresh}</li>
66
   *   <li>{@link java.util.Map#put}</li>
67
   *   <li>{@link java.util.Map#putAll}</li>
68
   *   <li>{@link java.util.Map#replace}</li>
69
   *   <li>{@link java.util.Map#computeIfPresent}</li>
70
   *   <li>{@link java.util.Map#compute}</li>
71
   *   <li>{@link java.util.Map#merge}</li>
72
   * </ul>
73
   */
74
  REPLACED {
×
75
    @Override public boolean wasEvicted() {
76
      return false;
×
77
    }
78
  },
79

80
  /**
81
   * The entry was removed automatically because its key or value was garbage-collected. This
82
   * can occur when using {@link Caffeine#weakKeys}, {@link Caffeine#weakValues}, or
83
   * {@link Caffeine#softValues}.
84
   */
85
  COLLECTED {
×
86
    @Override public boolean wasEvicted() {
87
      return true;
×
88
    }
89
  },
90

91
  /**
92
   * The entry's expiration timestamp has passed. This can occur when using
93
   * {@link Caffeine#expireAfterWrite}, {@link Caffeine#expireAfterAccess},
94
   * or {@link Caffeine#expireAfter(Expiry)}.
95
   */
96
  EXPIRED {
×
97
    @Override public boolean wasEvicted() {
98
      return true;
×
99
    }
100
  },
101

102
  /**
103
   * The entry was evicted due to size constraints. This can occur when using
104
   * {@link Caffeine#maximumSize} or {@link Caffeine#maximumWeight}.
105
   */
106
  SIZE {
×
107
    @Override public boolean wasEvicted() {
108
      return true;
×
109
    }
110
  };
111

112
  /**
113
   * Returns {@code true} if there was an automatic removal due to eviction (the cause is neither
114
   * {@link #EXPLICIT} nor {@link #REPLACED}).
115
   *
116
   * @return if the entry was automatically removed due to eviction
117
   */
118
  public abstract boolean wasEvicted();
119
}
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