• 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/processor/EntryProcessorEntry.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.processor;
17

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

20
import java.util.Optional;
21

22
import javax.cache.integration.CacheLoader;
23
import javax.cache.processor.EntryProcessor;
24
import javax.cache.processor.MutableEntry;
25

26
import org.jspecify.annotations.Nullable;
27

28
/**
29
 * An entry that is consumed by an {@link EntryProcessor}. The updates to the entry are replayed
30
 * on the cache when the processor completes.
31
 *
32
 * @author ben.manes@gmail.com (Ben Manes)
33
 */
34
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
35
public final class EntryProcessorEntry<K, V> implements MutableEntry<K, V> {
36
  private final boolean hasEntry;
37
  private final K key;
38

39
  private Action action;
40
  private @Nullable V value;
41
  private Optional<CacheLoader<K, V>> cacheLoader;
42

43
  public EntryProcessorEntry(K key, @Nullable V value, Optional<CacheLoader<K, V>> cacheLoader) {
×
44
    this.hasEntry = (value != null);
×
45
    this.cacheLoader = cacheLoader;
×
46
    this.action = Action.NONE;
×
47
    this.value = value;
×
48
    this.key = key;
×
49
  }
×
50

51
  @Override
52
  public boolean exists() {
53
    return (getValue() != null);
×
54
  }
55

56
  @Override
57
  public K getKey() {
58
    return key;
×
59
  }
60

61
  @Override
62
  @SuppressWarnings("ConstantValue")
63
  public @Nullable V getValue() {
64
    if (action != Action.NONE) {
×
65
      return value;
×
66
    } else if (value != null) {
×
67
      action = Action.READ;
×
68
    } else if (cacheLoader.isPresent()) {
×
69
      value = cacheLoader.orElseThrow().load(key);
×
70
      cacheLoader = Optional.empty();
×
71
      if (value != null) {
×
72
        action = Action.LOADED;
×
73
      }
74
    }
75
    return value;
×
76
  }
77

78
  @Override
79
  public void remove() {
80
    action = (action == Action.CREATED) ? Action.NONE : Action.DELETED;
×
81
    if (value != null) {
×
82
      value = null;
×
83
    }
84
  }
×
85

86
  @Override
87
  public void setValue(V value) {
88
    requireNonNull(value);
×
89
    if (action != Action.CREATED) {
×
90
      action = (hasEntry && exists()) ? Action.UPDATED : Action.CREATED;
×
91
    }
92
    this.value = value;
×
93
  }
×
94

95
  /** Returns the dominant action performed by the processor on the entry. */
96
  public Action getAction() {
97
    return action;
×
98
  }
99

100
  @Override
101
  public <T> T unwrap(Class<T> clazz) {
102
    if (!clazz.isInstance(this)) {
×
103
      throw new IllegalArgumentException("Class " + clazz + " is unknown to this implementation");
×
104
    }
105
    @SuppressWarnings("unchecked")
106
    var castedEntry = (T) this;
×
107
    return castedEntry;
×
108
  }
109

110
  @Override
111
  public String toString() {
112
    return key + "=" + getValue();
×
113
  }
114
}
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