| 1 | package pro.verron.officestamper.core; | |
| 2 | ||
| 3 | import org.jspecify.annotations.Nullable; | |
| 4 | import org.slf4j.Logger; | |
| 5 | import org.slf4j.LoggerFactory; | |
| 6 | import org.springframework.core.convert.TypeDescriptor; | |
| 7 | import org.springframework.expression.AccessException; | |
| 8 | import org.springframework.expression.EvaluationContext; | |
| 9 | import org.springframework.expression.MethodExecutor; | |
| 10 | import org.springframework.expression.MethodResolver; | |
| 11 | ||
| 12 | import java.util.List; | |
| 13 | ||
| 14 | record UnionMethodResolver(List<MethodResolver> resolvers) | |
| 15 | implements MethodResolver { | |
| 16 | private static final Logger log = LoggerFactory.getLogger(UnionMethodResolver.class); | |
| 17 | ||
| 18 | @Override | |
| 19 | @Nullable | |
| 20 | public MethodExecutor resolve( | |
| 21 | EvaluationContext context, | |
| 22 | Object target, | |
| 23 | String name, | |
| 24 | List<TypeDescriptor> argumentTypes | |
| 25 | ) { | |
| 26 |
1
1. resolve : negated conditional → KILLED |
if (!(target instanceof ContextBranch branch)) return null; |
| 27 | ||
| 28 | for (Object subTarget : branch.list()) { | |
| 29 | for (MethodResolver resolver : resolvers) { | |
| 30 | try { | |
| 31 | var executor = resolver.resolve(context, subTarget, name, argumentTypes); | |
| 32 |
2
1. resolve : replaced return value with null for pro/verron/officestamper/core/UnionMethodResolver::resolve → NO_COVERAGE 2. resolve : negated conditional → TIMED_OUT |
if (executor != null) return executor; |
| 33 | } catch (AccessException e) { | |
| 34 | log.atInfo() | |
| 35 | .setCause(e) | |
| 36 | .log("AccessException while resolving sub-target '{}' for method '{}'." | |
| 37 | + " Continue to next target.", subTarget, name); | |
| 38 | } | |
| 39 | } | |
| 40 | } | |
| 41 | return null; | |
| 42 | } | |
| 43 | } | |
Mutations | ||
| 26 |
1.1 |
|
| 32 |
1.1 2.2 |