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

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

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

50.0
today-context/src/main/java/infra/cache/interceptor/CacheOperationSourcePointcut.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.cache.interceptor;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.io.Serial;
23
import java.io.Serializable;
24
import java.lang.reflect.Method;
25

26
import infra.aop.ClassFilter;
27
import infra.aop.support.StaticMethodMatcherPointcut;
28
import infra.cache.CacheManager;
29
import infra.util.ObjectUtils;
30

31
/**
32
 * A Pointcut that matches if the underlying {@link CacheOperationSource}
33
 * has an attribute for a given method.
34
 *
35
 * @author Costin Leau
36
 * @author Juergen Hoeller
37
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
38
 * @since 4.0
39
 */
40
class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
41

42
  @Serial
43
  private static final long serialVersionUID = 1L;
44

45
  @Nullable
46
  private CacheOperationSource cacheOperationSource;
47

48
  public CacheOperationSourcePointcut() {
2✔
49
    setClassFilter(new CacheOperationSourceClassFilter());
6✔
50
  }
1✔
51

52
  public void setCacheOperationSource(@Nullable CacheOperationSource cacheOperationSource) {
53
    this.cacheOperationSource = cacheOperationSource;
3✔
54
  }
1✔
55

56
  @Override
57
  public boolean matches(Method method, Class<?> targetClass) {
58
    return (this.cacheOperationSource == null ||
8!
59
            this.cacheOperationSource.hasCacheOperations(method, targetClass));
5✔
60
  }
61

62
  @Override
63
  public boolean equals(@Nullable Object other) {
64
    return (this == other || (other instanceof CacheOperationSourcePointcut that &&
×
65
            ObjectUtils.nullSafeEquals(this.cacheOperationSource, that.cacheOperationSource)));
×
66
  }
67

68
  @Override
69
  public int hashCode() {
70
    return CacheOperationSourcePointcut.class.hashCode();
×
71
  }
72

73
  @Override
74
  public String toString() {
75
    return getClass().getName() + ": " + this.cacheOperationSource;
8✔
76
  }
77

78
  /**
79
   * {@link ClassFilter} that delegates to {@link CacheOperationSource#isCandidateClass}
80
   * for filtering classes whose methods are not worth searching to begin with.
81
   */
82
  private final class CacheOperationSourceClassFilter implements ClassFilter {
6✔
83

84
    @Override
85
    public boolean matches(Class<?> clazz) {
86
      if (CacheManager.class.isAssignableFrom(clazz)) {
4✔
87
        return false;
2✔
88
      }
89
      return (cacheOperationSource == null || cacheOperationSource.isCandidateClass(clazz));
13!
90
    }
91

92
    @Nullable
93
    private CacheOperationSource getCacheOperationSource() {
94
      return cacheOperationSource;
4✔
95
    }
96

97
    @Override
98
    public boolean equals(@Nullable Object other) {
99
      return (this == other || (other instanceof CacheOperationSourceClassFilter that &&
×
100
              ObjectUtils.nullSafeEquals(getCacheOperationSource(), that.getCacheOperationSource())));
×
101
    }
102

103
    @Override
104
    public int hashCode() {
105
      return CacheOperationSourceClassFilter.class.hashCode();
×
106
    }
107

108
    @Override
109
    public String toString() {
110
      return CacheOperationSourceClassFilter.class.getName() + ": " + getCacheOperationSource();
7✔
111
    }
112
  }
113

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

© 2026 Coveralls, Inc