UnionPropertyAccessor.java

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.PropertyAccessor;
7
import org.springframework.expression.TypedValue;
8
9
import java.util.List;
10
11
record UnionPropertyAccessor(List<PropertyAccessor> accessors)
12
        implements PropertyAccessor {
13
14
    @Override
15
    public Class<?>[] getSpecificTargetClasses() {
16 1 1. getSpecificTargetClasses : replaced return value with null for pro/verron/officestamper/core/UnionPropertyAccessor::getSpecificTargetClasses → TIMED_OUT
        return new Class[]{ContextBranch.class};
17
    }
18
19
    @Override
20
    public boolean canRead(EvaluationContext context, @Nullable Object target, String name)
21
            throws AccessException {
22 2 1. canRead : replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → NO_COVERAGE
2. canRead : negated conditional → TIMED_OUT
        if (!(target instanceof ContextBranch branch)) return false;
23
        for (Object subTarget : branch.list())
24
            for (PropertyAccessor accessor : accessors)
25 2 1. canRead : replaced boolean return with false for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → TIMED_OUT
2. canRead : negated conditional → TIMED_OUT
                if (accessor.canRead(context, subTarget, name)) return true;
26 1 1. canRead : replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → TIMED_OUT
        return false;
27
    }
28
29
    @Override
30
    public TypedValue read(EvaluationContext context, @Nullable Object target, String name)
31
            throws AccessException {
32 1 1. read : negated conditional → TIMED_OUT
        if (!(target instanceof ContextBranch branch))
33
            throw new AccessException("Target is not a ContextBranch");
34
35
        for (Object subTarget : branch.list()) {
36
            for (PropertyAccessor accessor : accessors) {
37 1 1. read : negated conditional → TIMED_OUT
                if (accessor.canRead(context, subTarget, name)) {
38 1 1. read : replaced return value with null for pro/verron/officestamper/core/UnionPropertyAccessor::read → TIMED_OUT
                    return accessor.read(context, subTarget, name);
39
                }
40
            }
41
        }
42
        throw new AccessException("Unable to read property '" + name + "' from any context object");
43
    }
44
45
    @Override
46
    public boolean canWrite(EvaluationContext context, @Nullable Object target, String name)
47
            throws AccessException {
48 2 1. canWrite : replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → NO_COVERAGE
2. canWrite : negated conditional → TIMED_OUT
        if (!(target instanceof ContextBranch branch)) return false;
49
        for (Object subTarget : branch.list())
50
            for (PropertyAccessor accessor : accessors)
51 2 1. canWrite : replaced boolean return with false for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → TIMED_OUT
2. canWrite : negated conditional → TIMED_OUT
                if (accessor.canWrite(context, subTarget, name)) return true;
52 1 1. canWrite : replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → NO_COVERAGE
        return false;
53
    }
54
55
    @Override
56
    public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue)
57
            throws AccessException {
58 1 1. write : negated conditional → TIMED_OUT
        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 (PropertyAccessor accessor : accessors) {
64 1 1. write : negated conditional → TIMED_OUT
                if (accessor.canWrite(context, subTarget, name)) {
65
                    try {
66 1 1. write : removed call to org/springframework/expression/PropertyAccessor::write → TIMED_OUT
                        accessor.write(context, subTarget, name, 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 property '" + name + "' to any context object");
77
    }
78
}

Mutations

16

1.1
Location : getSpecificTargetClasses
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionPropertyAccessor::getSpecificTargetClasses → TIMED_OUT

22

1.1
Location : canRead
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → NO_COVERAGE

2.2
Location : canRead
Killed by : none
negated conditional → TIMED_OUT

25

1.1
Location : canRead
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → TIMED_OUT

2.2
Location : canRead
Killed by : none
negated conditional → TIMED_OUT

26

1.1
Location : canRead
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canRead → TIMED_OUT

32

1.1
Location : read
Killed by : none
negated conditional → TIMED_OUT

37

1.1
Location : read
Killed by : none
negated conditional → TIMED_OUT

38

1.1
Location : read
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionPropertyAccessor::read → TIMED_OUT

48

1.1
Location : canWrite
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → NO_COVERAGE

2.2
Location : canWrite
Killed by : none
negated conditional → TIMED_OUT

51

1.1
Location : canWrite
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → TIMED_OUT

2.2
Location : canWrite
Killed by : none
negated conditional → TIMED_OUT

52

1.1
Location : canWrite
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/UnionPropertyAccessor::canWrite → NO_COVERAGE

58

1.1
Location : write
Killed by : none
negated conditional → TIMED_OUT

64

1.1
Location : write
Killed by : none
negated conditional → TIMED_OUT

66

1.1
Location : write
Killed by : none
removed call to org/springframework/expression/PropertyAccessor::write → TIMED_OUT

74

1.1
Location : write
Killed by : none
negated conditional → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.0