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

ben-manes / caffeine / #4904

15 Jun 2025 07:51PM UTC coverage: 99.974% (-0.03%) from 100.0%
#4904

push

github

ben-manes
increase branch coverage

12 of 12 new or added lines in 3 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

7736 of 7738 relevant lines covered (99.97%)

1.0 hits per line

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

88.24
/jcache/src/main/java/com/github/benmanes/caffeine/jcache/expiry/JCacheExpiryPolicy.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.expiry;
17

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

20
import java.io.Serializable;
21
import java.util.Objects;
22

23
import javax.cache.expiry.Duration;
24
import javax.cache.expiry.ExpiryPolicy;
25

26
import org.jspecify.annotations.Nullable;
27

28
/**
29
 * A customized expiration policy.
30
 *
31
 * @author ben.manes@gmail.com (Ben Manes)
32
 */
33
public final class JCacheExpiryPolicy implements ExpiryPolicy, Serializable {
34
  private static final long serialVersionUID = 1L;
35

36
  private final Duration creation;
37
  private final @Nullable Duration update;
38
  private final @Nullable Duration access;
39

40
  public JCacheExpiryPolicy(Duration creation,
41
      @Nullable Duration update, @Nullable Duration access) {
1✔
42
    this.creation = requireNonNull(creation);
1✔
43
    this.update = update;
1✔
44
    this.access = access;
1✔
45
  }
1✔
46

47
  @Override
48
  public Duration getExpiryForCreation() {
49
    return creation;
1✔
50
  }
51

52
  @Override
53
  public @Nullable Duration getExpiryForUpdate() {
54
    return update;
1✔
55
  }
56

57
  @Override
58
  public @Nullable Duration getExpiryForAccess() {
59
    return access;
1✔
60
  }
61

62
  @Override
63
  public boolean equals(@Nullable Object o) {
64
    if (o == this) {
1✔
UNCOV
65
      return true;
×
66
    } else if (!(o instanceof ExpiryPolicy)) {
1✔
67
      return false;
1✔
68
    }
69
    var policy = (ExpiryPolicy) o;
1✔
70
    return Objects.equals(creation, policy.getExpiryForCreation())
1✔
71
        && Objects.equals(update, policy.getExpiryForUpdate())
1✔
72
        && Objects.equals(access, policy.getExpiryForAccess());
1✔
73
  }
74

75
  @Override
76
  public int hashCode() {
UNCOV
77
    return Objects.hash(creation, update, access);
×
78
  }
79
}
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