• 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

0.0
today-context/src/main/java/infra/cache/interceptor/CacheOperationSource.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.lang.reflect.Method;
23
import java.util.Collection;
24

25
import infra.util.CollectionUtils;
26

27
/**
28
 * Interface used by {@link CacheInterceptor}. Implementations know how to source
29
 * cache operation attributes, whether from configuration, metadata attributes at
30
 * source level, or elsewhere.
31
 *
32
 * @author Costin Leau
33
 * @author Juergen Hoeller
34
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
35
 * @since 4.0
36
 */
37
public interface CacheOperationSource {
38

39
  /**
40
   * Determine whether the given class is a candidate for cache operations
41
   * in the metadata format of this {@code CacheOperationSource}.
42
   * <p>If this method returns {@code false}, the methods on the given class
43
   * will not get traversed for {@link #getCacheOperations} introspection.
44
   * Returning {@code false} is therefore an optimization for non-affected
45
   * classes, whereas {@code true} simply means that the class needs to get
46
   * fully introspected for each method on the given class individually.
47
   *
48
   * @param targetClass the class to introspect
49
   * @return {@code false} if the class is known to have no cache operation
50
   * metadata at class or method level; {@code true} otherwise. The default
51
   * implementation returns {@code true}, leading to regular introspection.
52
   * @see #hasCacheOperations
53
   */
54
  default boolean isCandidateClass(Class<?> targetClass) {
55
    return true;
×
56
  }
57

58
  /**
59
   * Determine whether there are cache operations for the given method.
60
   *
61
   * @param method the method to introspect
62
   * @param targetClass the target class (can be {@code null},
63
   * in which case the declaring class of the method must be used)
64
   * @see #getCacheOperations
65
   */
66
  default boolean hasCacheOperations(Method method, @Nullable Class<?> targetClass) {
67
    return CollectionUtils.isNotEmpty(getCacheOperations(method, targetClass));
×
68
  }
69

70
  /**
71
   * Return the collection of cache operations for this method,
72
   * or {@code null} if the method contains no <em>cacheable</em> annotations.
73
   *
74
   * @param method the method to introspect
75
   * @param targetClass the target class (can be {@code null}, in which case
76
   * the declaring class of the method must be used)
77
   * @return all cache operations for this method, or {@code null} if none found
78
   */
79
  @Nullable
80
  Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass);
81

82
}
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