| 1 | package pro.verron.officestamper.core; | |
| 2 | ||
| 3 | import org.jspecify.annotations.Nullable; | |
| 4 | import org.springframework.expression.AccessException; | |
| 5 | import org.springframework.expression.EvaluationContext; | |
| 6 | import org.springframework.expression.IndexAccessor; | |
| 7 | import org.springframework.expression.TypedValue; | |
| 8 | ||
| 9 | import java.util.List; | |
| 10 | ||
| 11 | record UnionIndexAccessor(List<IndexAccessor> accessors) | |
| 12 | implements IndexAccessor { | |
| 13 | ||
| 14 | @Override | |
| 15 | public Class<?>[] getSpecificTargetClasses() { | |
| 16 |
1
1. getSpecificTargetClasses : replaced return value with null for pro/verron/officestamper/core/UnionIndexAccessor::getSpecificTargetClasses → NO_COVERAGE |
return new Class[]{ContextBranch.class}; |
| 17 | } | |
| 18 | ||
| 19 | @Override | |
| 20 | public boolean canRead(EvaluationContext context, Object target, Object index) | |
| 21 | throws AccessException { | |
| 22 |
2
1. canRead : negated conditional → NO_COVERAGE 2. canRead : replaced boolean return with true for pro/verron/officestamper/core/UnionIndexAccessor::canRead → NO_COVERAGE |
if (!(target instanceof ContextBranch branch)) return false; |
| 23 | for (Object subTarget : branch.list()) | |
| 24 | for (IndexAccessor accessor : accessors) | |
| 25 |
2
1. canRead : negated conditional → NO_COVERAGE 2. canRead : replaced boolean return with false for pro/verron/officestamper/core/UnionIndexAccessor::canRead → NO_COVERAGE |
if (accessor.canRead(context, subTarget, index)) return true; |
| 26 |
1
1. canRead : replaced boolean return with true for pro/verron/officestamper/core/UnionIndexAccessor::canRead → NO_COVERAGE |
return false; |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public TypedValue read(EvaluationContext context, Object target, Object index) | |
| 31 | throws AccessException { | |
| 32 |
1
1. read : negated conditional → NO_COVERAGE |
if (!(target instanceof ContextBranch branch)) |
| 33 | throw new AccessException("Target is not a ContextBranch"); | |
| 34 | ||
| 35 | for (Object subTarget : branch.list()) { | |
| 36 | for (IndexAccessor accessor : accessors) { | |
| 37 |
1
1. read : negated conditional → NO_COVERAGE |
if (accessor.canRead(context, subTarget, index)) { |
| 38 |
1
1. read : replaced return value with null for pro/verron/officestamper/core/UnionIndexAccessor::read → NO_COVERAGE |
return accessor.read(context, subTarget, index); |
| 39 | } | |
| 40 | } | |
| 41 | } | |
| 42 | throw new AccessException("Unable to read index '" + index + "' from any context object"); | |
| 43 | } | |
| 44 | ||
| 45 | @Override | |
| 46 | public boolean canWrite(EvaluationContext context, Object target, Object index) | |
| 47 | throws AccessException { | |
| 48 |
2
1. canWrite : negated conditional → NO_COVERAGE 2. canWrite : replaced boolean return with true for pro/verron/officestamper/core/UnionIndexAccessor::canWrite → NO_COVERAGE |
if (!(target instanceof ContextBranch branch)) return false; |
| 49 | for (Object subTarget : branch.list()) | |
| 50 | for (IndexAccessor accessor : accessors) | |
| 51 |
2
1. canWrite : negated conditional → NO_COVERAGE 2. canWrite : replaced boolean return with false for pro/verron/officestamper/core/UnionIndexAccessor::canWrite → NO_COVERAGE |
if (accessor.canWrite(context, subTarget, index)) return true; |
| 52 |
1
1. canWrite : replaced boolean return with true for pro/verron/officestamper/core/UnionIndexAccessor::canWrite → NO_COVERAGE |
return false; |
| 53 | } | |
| 54 | ||
| 55 | @Override | |
| 56 | public void write(EvaluationContext context, @Nullable Object target, Object index, @Nullable Object newValue) | |
| 57 | throws AccessException { | |
| 58 |
1
1. write : negated conditional → NO_COVERAGE |
if (!(target instanceof ContextBranch branch)) |
| 59 | throw new AccessException("Target is not a ContextBranch"); | |
| 60 | ||
| 61 | AccessException lastException = null; | |
| 62 | for (Object subTarget : branch.list()) { | |
| 63 | for (IndexAccessor accessor : accessors) { | |
| 64 |
1
1. write : negated conditional → NO_COVERAGE |
if (accessor.canWrite(context, subTarget, index)) { |
| 65 | try { | |
| 66 |
1
1. write : removed call to org/springframework/expression/IndexAccessor::write → NO_COVERAGE |
accessor.write(context, subTarget, index, newValue); |
| 67 | return; | |
| 68 | } catch (AccessException e) { | |
| 69 | lastException = e; | |
| 70 | } | |
| 71 | } | |
| 72 | } | |
| 73 | } | |
| 74 |
1
1. write : negated conditional → NO_COVERAGE |
throw lastException != null |
| 75 | ? lastException | |
| 76 | : new AccessException("Unable to write index '" + index + "' to any context object"); | |
| 77 | } | |
| 78 | } | |
Mutations | ||
| 16 |
1.1 |
|
| 22 |
1.1 2.2 |
|
| 25 |
1.1 2.2 |
|
| 26 |
1.1 |
|
| 32 |
1.1 |
|
| 37 |
1.1 |
|
| 38 |
1.1 |
|
| 48 |
1.1 2.2 |
|
| 51 |
1.1 2.2 |
|
| 52 |
1.1 |
|
| 58 |
1.1 |
|
| 64 |
1.1 |
|
| 66 |
1.1 |
|
| 74 |
1.1 |