1 | package fr.sii.ogham.core.util.bean; | |
2 | ||
3 | import static fr.sii.ogham.core.util.bean.BeanWrapperUtils.isInvalid; | |
4 | ||
5 | import java.util.List; | |
6 | ||
7 | /** | |
8 | * A wrapper that wraps original bean and all nested property values (only | |
9 | * objects, not primitives). | |
10 | * | |
11 | * The aim is to abstract access to the bean and also to nested properties that | |
12 | * are beans. | |
13 | * | |
14 | * @author Aurélien Baudet | |
15 | * | |
16 | */ | |
17 | public class RecursiveBeanReadWrapper implements BeanReadWrapper { | |
18 | private final BeanReadWrapper delegate; | |
19 | private final BeanReadWrapperFactory recursiveFactory; | |
20 | ||
21 | public RecursiveBeanReadWrapper(Object bean) { | |
22 | this(new SimpleBeanReadWrapper(bean)); | |
23 | } | |
24 | ||
25 | public RecursiveBeanReadWrapper(BeanReadWrapper delegate) { | |
26 | this(delegate, new DefaultRecursiveBeanReadWrapperFactory()); | |
27 | } | |
28 | ||
29 | public RecursiveBeanReadWrapper(Object bean, BeanReadWrapperFactory recursiveFactory) { | |
30 | this(new SimpleBeanReadWrapper(bean), recursiveFactory); | |
31 | } | |
32 | | |
33 | public RecursiveBeanReadWrapper(BeanReadWrapper delegate, BeanReadWrapperFactory recursiveFactory) { | |
34 | super(); | |
35 | this.delegate = delegate; | |
36 | this.recursiveFactory = recursiveFactory; | |
37 | } | |
38 | ||
39 | @Override | |
40 | public Object getPropertyValue(String name) { | |
41 | Object value = delegate.getPropertyValue(name); | |
42 |
2
1. getPropertyValue : negated conditional → NO_COVERAGE 2. getPropertyValue : negated conditional → KILLED |
if (value == null) { |
43 | return null; | |
44 | } | |
45 |
2
1. getPropertyValue : negated conditional → NO_COVERAGE 2. getPropertyValue : negated conditional → KILLED |
if (isInvalid(value)) { |
46 |
2
1. getPropertyValue : replaced return value with null for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getPropertyValue → NO_COVERAGE 2. getPropertyValue : replaced return value with null for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getPropertyValue → KILLED |
return value; |
47 | } | |
48 |
2
1. getPropertyValue : replaced return value with null for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getPropertyValue → NO_COVERAGE 2. getPropertyValue : replaced return value with null for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getPropertyValue → KILLED |
return recursiveFactory.create(value); |
49 | } | |
50 | ||
51 | @Override | |
52 | public List<String> getProperties() { | |
53 |
1
1. getProperties : replaced return value with Collections.emptyList for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getProperties → NO_COVERAGE |
return delegate.getProperties(); |
54 | } | |
55 | ||
56 | @Override | |
57 | public Object getWrappedBean() { | |
58 |
1
1. getWrappedBean : replaced return value with null for fr/sii/ogham/core/util/bean/RecursiveBeanReadWrapper::getWrappedBean → NO_COVERAGE |
return delegate.getWrappedBean(); |
59 | } | |
60 | } | |
Mutations | ||
42 |
1.1 2.2 |
|
45 |
1.1 2.2 |
|
46 |
1.1 2.2 |
|
48 |
1.1 2.2 |
|
53 |
1.1 |
|
58 |
1.1 |