• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ExpediaGroup / bull / #945

19 Apr 2024 01:22PM UTC coverage: 100.0%. Remained the same
#945

push

web-flow
Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.3 to 3.2.4 (#492)

* Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.3 to 3.2.4

Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.3 to 3.2.4.
- [Release notes](https://github.com/apache/maven-gpg-plugin/releases)
- [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.3...maven-gpg-plugin-3.2.4)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-gpg-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Trigger notification

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Fabio Borriello <fborriello@expediagroup.com>

1198 of 1198 relevant lines covered (100.0%)

1.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/bull-bean-transformer/src/main/java/com/expediagroup/beans/transformer/AbstractBeanTransformer.java
1
/**
2
 * Copyright (C) 2019-2023 Expedia, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.expediagroup.beans.transformer;
17

18
import static java.util.Arrays.asList;
19

20
import static com.expediagroup.transformer.validator.Validator.notNull;
21

22
import com.expediagroup.beans.conversion.analyzer.ConversionAnalyzer;
23
import com.expediagroup.transformer.AbstractTransformer;
24
import com.expediagroup.transformer.model.TransformerSettings;
25
import com.expediagroup.transformer.validator.Validator;
26
import com.expediagroup.transformer.validator.ValidatorImpl;
27

28
/**
29
 * Utility methods for populating Mutable, Immutable and Hybrid JavaBeans properties via reflection.
30
 * Contains all method implementation that will be common to any {@link BeanTransformer} implementation.
31
 */
32
abstract class AbstractBeanTransformer extends AbstractTransformer<BeanTransformer, String, TransformerSettings<String>> implements BeanTransformer {
33
    /**
34
     * The cache key prefix for the Transformer Functions.
35
     */
36
    static final String TRANSFORMER_FUNCTION_CACHE_PREFIX = "BeanTransformerFunction";
37

38
    /**
39
     * Bean Validator. It offers the possibility to validate a given Java Bean against a set of defined constraints.
40
     */
41
    Validator validator;
42

43
    /**
44
     * Conversion analyzer. It allows to automatically convert common field types.
45
     */
46
    ConversionAnalyzer conversionAnalyzer;
47

48
    /**
49
     * Default constructor.
50
     */
51
    AbstractBeanTransformer() {
52
        super(TRANSFORMER_FUNCTION_CACHE_PREFIX, "beanTransformer", new TransformerSettings<>());
2✔
53
    }
2✔
54

55
    /**
56
     * {@inheritDoc}
57
     */
58
    @Override
59
    public final BeanTransformer setDefaultValueForMissingField(final boolean useDefaultValue) {
60
        settings.setSetDefaultValueForMissingField(useDefaultValue);
2✔
61
        return this;
2✔
62
    }
63

64
    /**
65
     * {@inheritDoc}
66
     */
67
    @Override
68
    public BeanTransformer setDefaultValueForMissingPrimitiveField(final boolean useDefaultValue) {
69
        settings.setDefaultValueForMissingPrimitiveField(useDefaultValue);
2✔
70
        return this;
2✔
71
    }
72

73
    /**
74
     * {@inheritDoc}
75
     */
76
    @Override
77
    public final BeanTransformer setFlatFieldNameTransformation(final boolean useFlatTransformation) {
78
        settings.setFlatFieldNameTransformation(useFlatTransformation);
2✔
79
        return this;
2✔
80
    }
81

82
    /**
83
     * {@inheritDoc}
84
     */
85
    @Override
86
    public BeanTransformer setValidationEnabled(final boolean validationEnabled) {
87
        settings.setValidationEnabled(validationEnabled);
2✔
88
        if (validationEnabled) {
2✔
89
            validator = new ValidatorImpl();
2✔
90
        }
91
        return this;
2✔
92
    }
93

94
    /**
95
     * {@inheritDoc}
96
     */
97
    @Override
98
    public BeanTransformer setPrimitiveTypeConversionEnabled(final boolean primitiveTypeConversionEnabled) {
99
        settings.setPrimitiveTypeConversionEnabled(primitiveTypeConversionEnabled);
2✔
100
        if (primitiveTypeConversionEnabled) {
2✔
101
            conversionAnalyzer = new ConversionAnalyzer();
2✔
102
        } else {
103
            cacheManager.removeMatchingKeys(transformerFunctionRegex);
2✔
104
        }
105
        return this;
2✔
106
    }
107

108
    /**
109
     * {@inheritDoc}
110
     */
111
    @Override
112
    public BeanTransformer setCustomBuilderTransformationEnabled(final boolean customBuilderTransformationEnabled) {
113
        settings.setCustomBuilderTransformationEnabled(customBuilderTransformationEnabled);
2✔
114
        return this;
2✔
115
    }
116

117
    /**
118
     * {@inheritDoc}
119
     */
120
    @Override
121
    public final <T, K> K transform(final T sourceObj, final Class<? extends K> targetClass) {
122
        notNull(sourceObj, "The object to copy cannot be null!");
2✔
123
        notNull(targetClass, "The destination class cannot be null!");
2✔
124
        return transform(sourceObj, targetClass, null);
2✔
125
    }
126

127
    /**
128
     * Copies all properties from an object to a new one.
129
     * @param sourceObj the source object
130
     * @param targetClass the destination object class
131
     * @param breadcrumb the full path of the current field starting from his ancestor
132
     * @param <T> the Source object type
133
     * @param <K> the target object type
134
     * @return a copy of the source object into the destination object
135
     */
136
    protected abstract <T, K> K transform(T sourceObj, Class<? extends K> targetClass, String breadcrumb);
137

138
    /**
139
     * {@inheritDoc}
140
     */
141
    @Override
142
    public final <T, K> void transform(final T sourceObj, final K targetObject) {
143
        notNull(sourceObj, "The object to copy cannot be null!");
2✔
144
        notNull(targetObject, "The destination object cannot be null!");
2✔
145
        transform(sourceObj, targetObject, null);
2✔
146
    }
2✔
147

148
    /**
149
     * {@inheritDoc}
150
     */
151
    @Override
152
    public BeanTransformer skipTransformationForField(final String... fieldName) {
153
        if (fieldName.length != 0) {
2✔
154
            settings.getFieldsToSkip().addAll(asList(fieldName));
2✔
155
        }
156
        return this;
2✔
157
    }
158

159
    @Override
160
    public void resetFieldsTransformationSkip() {
161
        settings.getFieldsToSkip().clear();
2✔
162
    }
2✔
163

164
    /**
165
     * Copies all properties from an object to a new one.
166
     * @param sourceObj the source object
167
     * @param targetObject the destination object
168
     * @param breadcrumb the full path of the current field starting from his ancestor
169
     * @param <T> the Source object type
170
     * @param <K> the target object type
171
     */
172
    protected abstract <T, K> void transform(T sourceObj, K targetObject, String breadcrumb);
173
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc