Skip to content

Commit

Permalink
Merge 1d5a53d into 014f60e
Browse files Browse the repository at this point in the history
  • Loading branch information
fborriello committed Jun 23, 2021
2 parents 014f60e + 1d5a53d commit 4e5a805
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

All notable changes to this project will be documented in this file.

### [2.0.1] 2021.06.23
#### Changed
* Fixes an issue that was preventing the transformation of Object type fields

### [2.0.0] 2021.06.18
#### Added
* Increase the jdk version to 15
* Enables the [Java Record](https://blogs.oracle.com/javamagazine/records-come-to-java) transformation

### [1.7.7] 2021.06.23
#### Changed
* Fixes an issue that was preventing the transformation of Object type fields

### [1.7.6] 2021.01.11
#### Added
* Provides new module `bull-bom` that includes all the project modules
Expand Down
2 changes: 1 addition & 1 deletion bull-bean-transformer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.hotels.beans</groupId>
<artifactId>bean-utils-library-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ public class TransformerImpl extends AbstractBeanTransformer {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
protected final <T, K> K transform(final T sourceObj, final Class<? extends K> targetClass, final String breadcrumb) {
final K k;
final Optional<Class<?>> builderClass = getBuilderClass(targetClass);
if (builderClass.isPresent()) {
k = injectThroughBuilder(sourceObj, targetClass, builderClass.get(), breadcrumb);
if (targetClass.equals(Object.class)) {
k = (K) sourceObj;
} else {
k = injectValues(sourceObj, targetClass, breadcrumb);
final Optional<Class<?>> builderClass = getBuilderClass(targetClass);
if (builderClass.isPresent()) {
k = injectThroughBuilder(sourceObj, targetClass, builderClass.get(), breadcrumb);
} else {
k = injectValues(sourceObj, targetClass, breadcrumb);
}
}
if (settings.isValidationEnabled()) {
validator.validate(k);
Expand Down Expand Up @@ -176,7 +181,7 @@ private <T, K> K injectValues(final T sourceObj, final Class<K> targetClass, fin
* @throws InvalidBeanException {@link InvalidBeanException} if the target object is not compliant with the requirements
*/
protected <T, K> K handleInjectionException(final T sourceObj, final Class<K> targetClass, final Constructor constructor, final String breadcrumb,
final Object[] constructorArgs, final boolean forceConstructorInjection, final Exception e) {
final Object[] constructorArgs, final boolean forceConstructorInjection, final Exception e) {
String errorMsg;
if (!classUtils.areParameterNamesAvailable(constructor)) {
if (!forceConstructorInjection) {
Expand Down Expand Up @@ -447,8 +452,8 @@ private <T, K> Object getFieldValue(final T sourceObj, final String sourceFieldN
*/
@SuppressWarnings("unchecked")
private Object getTransformedValue(final FieldTransformer transformerFunction, final Object fieldValue,
final Class<?> sourceObjectClass, final String sourceFieldName, final Field field,
final boolean isDestinationFieldPrimitiveType, final String breadcrumb) {
final Class<?> sourceObjectClass, final String sourceFieldName, final Field field,
final boolean isDestinationFieldPrimitiveType, final String breadcrumb) {
Object transformedValue = fieldValue;
if (settings.isPrimitiveTypeConversionEnabled() && isDestinationFieldPrimitiveType) {
transformedValue = applyPrimitiveTypeConversion(sourceObjectClass, sourceFieldName, field, breadcrumb, transformedValue);
Expand Down Expand Up @@ -546,7 +551,7 @@ private FieldTransformer getTransformerFunction(final Field field, final String
*/
@SuppressWarnings("unchecked")
private Object applyPrimitiveTypeConversion(final Class<?> sourceObjectClass, final String sourceFieldName,
final Field field, final String fieldTransformerKey, final Object fieldValue) {
final Field field, final String fieldTransformerKey, final Object fieldValue) {
Object transformedValue = fieldValue;
FieldTransformer primitiveTypeTransformer = getPrimitiveTypeTransformer(sourceObjectClass, sourceFieldName, field, fieldTransformerKey);
if (nonNull(primitiveTypeTransformer)) {
Expand All @@ -564,7 +569,7 @@ private Object applyPrimitiveTypeConversion(final Class<?> sourceObjectClass, fi
* @return the default type transformer function
*/
private FieldTransformer getPrimitiveTypeTransformer(final Class<?> sourceObjectClass, final String sourceFieldName,
final Field field, final String fieldTransformerKey) {
final Field field, final String fieldTransformerKey) {
String cacheKey = TRANSFORMER_FUNCTION_CACHE_PREFIX + "-" + field.getDeclaringClass().getName() + "-" + fieldTransformerKey + "-" + field.getName();
return cacheManager.getFromCache(cacheKey, FieldTransformer.class)
.orElseGet(() -> {
Expand Down
2 changes: 1 addition & 1 deletion bull-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.hotels.beans</groupId>
<artifactId>bean-utils-library-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bull-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.hotels.beans</groupId>
<artifactId>bean-utils-library-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bull-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.hotels.beans</groupId>
<artifactId>bean-utils-library-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bull-map-transformer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>bean-utils-library-parent</artifactId>
<groupId>com.hotels.beans</groupId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
2 changes: 1 addition & 1 deletion bull-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>bean-utils-library-parent</artifactId>
<groupId>com.hotels.beans</groupId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>com.hotels.beans</groupId>
<artifactId>bean-utils-library-parent</artifactId>
<url>https://github.com/HotelsDotCom/bull</url>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<inceptionYear>2019</inceptionYear>
<description>
Expand Down

0 comments on commit 4e5a805

Please sign in to comment.