• 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

48.57
today-context/src/main/java/infra/cache/interceptor/CompositeCacheOperationSource.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.Serializable;
23
import java.lang.reflect.Method;
24
import java.util.ArrayList;
25
import java.util.Collection;
26

27
import infra.lang.Assert;
28

29
/**
30
 * Composite {@link CacheOperationSource} implementation that iterates
31
 * over a given array of {@code CacheOperationSource} instances.
32
 *
33
 * @author Costin Leau
34
 * @author Juergen Hoeller
35
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
36
 * @since 4.0
37
 */
38
@SuppressWarnings("serial")
39
public class CompositeCacheOperationSource implements CacheOperationSource, Serializable {
40

41
  private final CacheOperationSource[] cacheOperationSources;
42

43
  /**
44
   * Create a new CompositeCacheOperationSource for the given sources.
45
   *
46
   * @param cacheOperationSources the CacheOperationSource instances to combine
47
   */
48
  public CompositeCacheOperationSource(CacheOperationSource... cacheOperationSources) {
2✔
49
    Assert.notEmpty(cacheOperationSources, "CacheOperationSource array must not be empty");
3✔
50
    this.cacheOperationSources = cacheOperationSources;
3✔
51
  }
1✔
52

53
  /**
54
   * Return the {@code CacheOperationSource} instances that this
55
   * {@code CompositeCacheOperationSource} combines.
56
   */
57
  public final CacheOperationSource[] getCacheOperationSources() {
58
    return this.cacheOperationSources;
×
59
  }
60

61
  @Override
62
  public boolean isCandidateClass(Class<?> targetClass) {
63
    for (CacheOperationSource source : this.cacheOperationSources) {
×
64
      if (source.isCandidateClass(targetClass)) {
×
65
        return true;
×
66
      }
67
    }
68
    return false;
×
69
  }
70

71
  @Override
72
  public boolean hasCacheOperations(Method method, @Nullable Class<?> targetClass) {
73
    for (CacheOperationSource source : this.cacheOperationSources) {
×
74
      if (source.hasCacheOperations(method, targetClass)) {
×
75
        return true;
×
76
      }
77
    }
78
    return false;
×
79
  }
80

81
  @Override
82
  @Nullable
83
  public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
84
    Collection<CacheOperation> ops = null;
2✔
85
    for (CacheOperationSource source : this.cacheOperationSources) {
17✔
86
      Collection<CacheOperation> cacheOperations = source.getCacheOperations(method, targetClass);
5✔
87
      if (cacheOperations != null) {
2✔
88
        if (ops == null) {
2!
89
          ops = new ArrayList<>();
4✔
90
        }
91
        ops.addAll(cacheOperations);
4✔
92
      }
93
    }
94
    return ops;
2✔
95
  }
96

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