Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@BeanConstruct does not map collection constructor arguments #130

Closed
sptdevos opened this issue Dec 17, 2019 · 1 comment
Closed

@BeanConstruct does not map collection constructor arguments #130

sptdevos opened this issue Dec 17, 2019 · 1 comment
Assignees
Labels
bug fix-developed A fix has been developed, and is set to be included in the coming release.

Comments

@sptdevos
Copy link
Member

When Using @BeanConstruct to let BeanMapper make use of a constructor instead of setters to insert mapped fields in the target object, collection items are not mapped; the type of the items stays the source type.

Enclosed a failing test that tests this scenario (remove the List field from source and target to make the test succeed):

import java.util.List;

import io.beanmapper.annotations.BeanConstruct;
import io.beanmapper.config.BeanMapperBuilder;

import org.junit.Assert;
import org.junit.Test;

public class BeanConstructTest {

    @Test
    public void beanConstruct_shouldUse_argsConstructor() {
        NestedSource nestedSource = new NestedSource();
        nestedSource.nestedField = 42;

        Source source = new Source();
        source.field1 = 40;
        source.field2 = 41;
        source.nested = List.of(nestedSource);

        Target target = new BeanMapperBuilder().build().map(source, Target.class);
        Assert.assertEquals(Integer.valueOf(40), target.getField1());
        Assert.assertEquals(Integer.valueOf(41), target.getField2());
        Assert.assertEquals(Integer.valueOf(42), target.getNested().get(0).getNestedField());
    }

    public static class Source {
        public Integer field1;
        public Integer field2;
        public List<NestedSource> nested;
    }

    public static class NestedSource {
        public Integer nestedField;
    }

    @BeanConstruct({"field1", "field2", "nested"})
    public static class Target {
        private Integer field1;
        private Integer field2;
        private List<NestedTarget> nested;

        public Target(Integer field1, Integer field2, List<NestedTarget> nested) {
            this.field1 = field1;
            this.field2 = field2;
            this.nested = nested;
        }

        public Integer getField1() {
            return field1;
        }

        public Integer getField2() {
            return field2;
        }

        public List<NestedTarget> getNested() {
            return nested;
        }

    }

    public static class NestedTarget {

        private Integer nestedField;

        public Integer getNestedField() {
            return nestedField;
        }

        public void setNestedField(Integer nestedField) {
            this.nestedField = nestedField;
        }
    }
}
@sptdevos sptdevos added the bug label Dec 17, 2019
@marcus-talbot42 marcus-talbot42 self-assigned this Oct 27, 2022
marcus-talbot42 added a commit that referenced this issue Oct 27, 2022
- By looping through the constructor arguments, we can map every object
  of one of several types, to the type of the corresponding parameter in
  the constructor.
- Using @sptdevos' tests to confirm proper functionality.
marcus-talbot42 added a commit that referenced this issue Oct 28, 2022
- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md
marcus-talbot42 added a commit that referenced this issue Oct 28, 2022
- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md
marcus-talbot42 added a commit that referenced this issue Oct 28, 2022
- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md
@marcus-talbot42
Copy link
Contributor

Fix is available in dev/4.1.0

@marcus-talbot42 marcus-talbot42 added the fix-developed A fix has been developed, and is set to be included in the coming release. label Nov 8, 2022
marcus-talbot42 added a commit that referenced this issue Nov 9, 2022
Process Feedback in preparation of release.

- Renamed RecordConstruct, to BeanRecordConstruct, to comply with
  naming conventions.
- Renamed RecordConstructMode, to BeanRecordConstructMode, to comply
  naming conventions.
- Replaced FlushAfterClearInstruction-enum with the more widely-usable
  Trinary-enum.
- Retouched DefaultBeanInitializer, to use BeanMapper's utility methods
  as much as possible.
- Updated CHANGELOG.md

Added arbitrarily deep Optional Mapping

- BeanMapper#map(Optional, Class) should now allow for mapping of
  Optional<Optional<?>> to a target class. Every Optional may also
  contain another Optional. The only limit is the recursion limit.
- It is now possible to automatically map Optional<X> to Optional<Y>,
due to changes in the OptionalToObjectConverter.
- Supports mapping Optional<List<X>> to Optional<List<Y>>. Same for
  Sets.
- Added mapping Optional<Map<X>> to Optional<Map<Y>>.

Fixes FieldShadowingException for ignored fields.

- Ignoring fields with BeanIgnore-annotation when detecting field
  shadowing.
- Fixed problem with getting a class using the name of an accessor.

Fix for #132

- Added BeanMatchStore#detectBeanPropertyFieldShadowing(PropertyAccessor
  , io.beanmapper.annotations.BeanProperty), which detects field
  shadowing and throws a FieldShadowingException when appropriate.

Added Mapping to and from Record-classes

- Improved the use of generics in BeanConverter, and its derived
  classes.
- Changed AbstractBeanConverter#convert, to allow the mapping of null to
  primitives, by using the default value for the relevant primitive,
  using Configuration#getDefaultValuesForClass(Class).
- Modified AbstractMapStrategy#convert, to offer null-values to
  BeanConverters.
- Added AssertionUtils to tests, containing some useful macros for
  certain tedious-to-write assertions.
- Added documentation to BeanAlias, to - hopefully - make it easier to
  understand its purpose, and map its valid use-cases.
- Improved the use of generics in the BeanMapper-class.
- Added the RecordToAnyConverter to the default converters in
  BeanMapperBuilder#addDefaultConverters().
- Added BeanMapperBuilder#addCustomDefaultValue(Class, Object), which
  allows users to set their own defaults, even allowing defaults for
  complex objects.
- Added MappingException, to create a common super-class for exceptions
  relating to bean-mapping and record-mapping.
- Replaced conditionals where an annotation is compared with null with
  usages of Class#isAnnotationPresent(Class).
- Added ClassGenerator#createClassDerivedFromRecord(Class, Set<String>),
  which dynamically creates a class based off of a Record-class, setting
  the field-modifiers to public.
- Added PropertyAccessor#isAnnotationPresent(Class), which checks
  whether the given annotation-class is present on the accessor.
- Added Configuration#addCustomDefaultValueForClass(Class, Object),
  which allows users to set default values for any type during runtime.
- Added Configuration#getDefaultValueForClass(Class), which allows the
  user to retrieve a default value mapped to a given class. This method
  will search the custom default values first, the default values in the
  DefaultValues-class second, and lastly, if no value is found, will
  return null.
- Added check to ConstructorArguments-constructor, to ensure that the
  constructorArgs-array is never null.
- Added a Map<Class, Object> to CoreConfiguration and
  OverrideConfiguration, to allow for the storing of custom default
  values.
- Modified DefaultBeanInitializer#mapParameterizedArguments, to pass a
  ParameterizedType to BeanMapper#map(Object, ParameterizedType) when
  appropriate.
- Added defaults for Optional, List, Set and Map to DefaultValues.
- Using unsupported methods in the PropertyAccessor-implementations now
  result in an UnsupportedOperationException being thrown.
- Improved usage of generics in MapStrategy and implementing classes.
- Modified MapToClassStrategy#map(Object) to let the
  RecordToAnyConverter handle a source Record.
- Added MapToRecordStrategy, which is used to map a source to a Record.
  Somewhat similar to the way a class annotated with BeanConstruct is
  mapped.
- Instances where Field#setAccessible(boolean) is called, are now
  preceded by a check to make certain that those fields are
  inaccessible.
- PrimitiveConvert will no longer throw an Exception when null is passed
  as the source to
  PrimitiveConverter#convert(BeanMapper, Object, Class,
  BeanPropertyMatch). Rather, the default value for the target-class is
  retrieved and returned.
- Added PropertyAccessors#findPropertyDescriptorsForRecord(Class), which
  compiles a Map<String, PropertyDescriptor>, based on the names of the
  RecordComponent-objects of the Record, and their accessors.
- Added RecordConstruct, which provides runtime-instructions to
  BeanMapper.
- Added RecordConstructMode, can be used to set which constructor in a
  Record should be used, or excluded, by BeanMapper, while mapping to a
  Record.
- Added RecordConstructorConflictException, which will be thrown while
  attempting to map to a record which has multiple constructors set with
  the constructMode-option set to RecordConstructMode.FORCE. Notifies
  the user of the constructors with the conflicting constructors.
- Added RecordToAnyConverter, which is used to dynamically create a
  class, based off of the source Record. The dynamically generated class
  is then used as an intermediary between the Record and the
  target-class.
- Added SourceFieldAccessException, which is thrown when the
  MapToRecordStrategy cannot access a field in the target Record.
- Replaced all instances of String#format with String#formatted.
- Removed slf4j-api dependency, as it is transitive through
  jcl-over-slf4j.
- Added tests to improve coverage.
- Updated CHANGELOG.md.

Fix for issue #168

- By catching Throwable, and saving Throwable in the List, rather than
  exception, the test should work correctly, and fail when it should.

Fix for issue #166

- Modified ClassGenerator#createClass, to check whether a generated
  field is annotated with BeanAlias. If so, the name of the generated
  field will be set to the value on the BeanAlias-annotation, and the
  annotation will be removed from the generated field.

Fix for issue #130

- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md

Added array-mapping

- Added BeanMapper#map(Object[], Class) allowing users to map an array
  to a new array of the given type.
- Added tests.
- Updated CHANGELOG.md

Added Queue-mapping

- Added BeanMapper#map(Queue, Class)
- Improved BeanMapperTest#mapQueueToTarget_PriorityQueue()
- Updated CHANGELOG.md

Set jackson-databind version to latest stable

Removed deprecated

- Removed BeanMapper#config().
- Removed BeanMapper#wrapConfig().
- Removed BeanMapperAware.java.
- Updated CHANGELOG.md

Converted BeanMapper from record, back to class.

Auto-reformat using MAD-style

Replaced NOPs in OverrideConfiguration with suitable Exceptions.

- OverrideConfiguration#withoutDefaultConverters throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addLogicSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addCollectionHandler throws a
  BeanConfigurationOperationNotAllowedException(String)
- OverrideConfiguration#addProxySkipClass throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(Class<?>) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(String) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addAfterClearFlusher throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setRoleSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setBeanUnproxy throws a
  BeanConfigurationOperationNotAllowedException(String).
- Updated tests.
- Updated CHANGELOG.md.

Replaced usages of Boolean-class, with primitive or enum.

- Replaced the OverrideConfiguration#flushAfterClear-Boolean with enum
  FlushAfterClearInstruction. The FlushAfterClearInstruction-enum, just
  like the Boolean-wrapper, allows for three values:
  FlushAfterClearInstruction#FLUSH_ENABLED (true),
  FlushAfterClearInstruction#FLUSH_DISABLED (false) and
  FlushAfterClearInstruction#UNSET (null). Using this enum mitigates the
  unpleasant usage of the Boolean-class, and should prevent NPEs.
- Replaced the usage of Boolean with the primitive boolean, wherever
  possible.
- Updated tests where necessary.
- Updated CHANGELOG.md

Methods that return a collection will always return a non-null object.

- Every method that returns a collection that may be null, will check
  whether the collection is null. If the collection is null, the method
  will return an empty, immutable collection of the correct type.
- Updated relevant tests to reflect that methods returning a collection
  will never return null when a collection is required.
- Updated CHANGELOG.md

Added Collection and Queue mapping

- Added BeanMapper#map(Collection, Class), allowing users to map from a
  Collection to the actual type of the Collection automatically.
- Added QueueCollectionHandler, allowing mapping of subtypes of the
  Queue-interface.

Bumped jackson-databind dependency

- Bumped the jackson-databind dependency up to version 2.14.0-rc1, due
  to a transitive vulnerability.
- Extracted plugin-versions to properties.

Updated dependencies and CHANGELOG.md
marcus-talbot42 added a commit that referenced this issue Nov 9, 2022
Process Feedback in preparation of release.

- Renamed RecordConstruct, to BeanRecordConstruct, to comply with
  naming conventions.
- Renamed RecordConstructMode, to BeanRecordConstructMode, to comply
  naming conventions.
- Replaced FlushAfterClearInstruction-enum with the more widely-usable
  Trinary-enum.
- Retouched DefaultBeanInitializer, to use BeanMapper's utility methods
  as much as possible.
- Updated CHANGELOG.md

Added arbitrarily deep Optional Mapping

- BeanMapper#map(Optional, Class) should now allow for mapping of
  Optional<Optional<?>> to a target class. Every Optional may also
  contain another Optional. The only limit is the recursion limit.
- It is now possible to automatically map Optional<X> to Optional<Y>,
due to changes in the OptionalToObjectConverter.
- Supports mapping Optional<List<X>> to Optional<List<Y>>. Same for
  Sets.
- Added mapping Optional<Map<X>> to Optional<Map<Y>>.

Fixes FieldShadowingException for ignored fields.

- Ignoring fields with BeanIgnore-annotation when detecting field
  shadowing.
- Fixed problem with getting a class using the name of an accessor.

Fix for #132

- Added BeanMatchStore#detectBeanPropertyFieldShadowing(PropertyAccessor
  , io.beanmapper.annotations.BeanProperty), which detects field
  shadowing and throws a FieldShadowingException when appropriate.

Added Mapping to and from Record-classes

- Improved the use of generics in BeanConverter, and its derived
  classes.
- Changed AbstractBeanConverter#convert, to allow the mapping of null to
  primitives, by using the default value for the relevant primitive,
  using Configuration#getDefaultValuesForClass(Class).
- Modified AbstractMapStrategy#convert, to offer null-values to
  BeanConverters.
- Added AssertionUtils to tests, containing some useful macros for
  certain tedious-to-write assertions.
- Added documentation to BeanAlias, to - hopefully - make it easier to
  understand its purpose, and map its valid use-cases.
- Improved the use of generics in the BeanMapper-class.
- Added the RecordToAnyConverter to the default converters in
  BeanMapperBuilder#addDefaultConverters().
- Added BeanMapperBuilder#addCustomDefaultValue(Class, Object), which
  allows users to set their own defaults, even allowing defaults for
  complex objects.
- Added MappingException, to create a common super-class for exceptions
  relating to bean-mapping and record-mapping.
- Replaced conditionals where an annotation is compared with null with
  usages of Class#isAnnotationPresent(Class).
- Added ClassGenerator#createClassDerivedFromRecord(Class, Set<String>),
  which dynamically creates a class based off of a Record-class, setting
  the field-modifiers to public.
- Added PropertyAccessor#isAnnotationPresent(Class), which checks
  whether the given annotation-class is present on the accessor.
- Added Configuration#addCustomDefaultValueForClass(Class, Object),
  which allows users to set default values for any type during runtime.
- Added Configuration#getDefaultValueForClass(Class), which allows the
  user to retrieve a default value mapped to a given class. This method
  will search the custom default values first, the default values in the
  DefaultValues-class second, and lastly, if no value is found, will
  return null.
- Added check to ConstructorArguments-constructor, to ensure that the
  constructorArgs-array is never null.
- Added a Map<Class, Object> to CoreConfiguration and
  OverrideConfiguration, to allow for the storing of custom default
  values.
- Modified DefaultBeanInitializer#mapParameterizedArguments, to pass a
  ParameterizedType to BeanMapper#map(Object, ParameterizedType) when
  appropriate.
- Added defaults for Optional, List, Set and Map to DefaultValues.
- Using unsupported methods in the PropertyAccessor-implementations now
  result in an UnsupportedOperationException being thrown.
- Improved usage of generics in MapStrategy and implementing classes.
- Modified MapToClassStrategy#map(Object) to let the
  RecordToAnyConverter handle a source Record.
- Added MapToRecordStrategy, which is used to map a source to a Record.
  Somewhat similar to the way a class annotated with BeanConstruct is
  mapped.
- Instances where Field#setAccessible(boolean) is called, are now
  preceded by a check to make certain that those fields are
  inaccessible.
- PrimitiveConvert will no longer throw an Exception when null is passed
  as the source to
  PrimitiveConverter#convert(BeanMapper, Object, Class,
  BeanPropertyMatch). Rather, the default value for the target-class is
  retrieved and returned.
- Added PropertyAccessors#findPropertyDescriptorsForRecord(Class), which
  compiles a Map<String, PropertyDescriptor>, based on the names of the
  RecordComponent-objects of the Record, and their accessors.
- Added RecordConstruct, which provides runtime-instructions to
  BeanMapper.
- Added RecordConstructMode, can be used to set which constructor in a
  Record should be used, or excluded, by BeanMapper, while mapping to a
  Record.
- Added RecordConstructorConflictException, which will be thrown while
  attempting to map to a record which has multiple constructors set with
  the constructMode-option set to RecordConstructMode.FORCE. Notifies
  the user of the constructors with the conflicting constructors.
- Added RecordToAnyConverter, which is used to dynamically create a
  class, based off of the source Record. The dynamically generated class
  is then used as an intermediary between the Record and the
  target-class.
- Added SourceFieldAccessException, which is thrown when the
  MapToRecordStrategy cannot access a field in the target Record.
- Replaced all instances of String#format with String#formatted.
- Removed slf4j-api dependency, as it is transitive through
  jcl-over-slf4j.
- Added tests to improve coverage.
- Updated CHANGELOG.md.

Fix for issue #168

- By catching Throwable, and saving Throwable in the List, rather than
  exception, the test should work correctly, and fail when it should.

Fix for issue #166

- Modified ClassGenerator#createClass, to check whether a generated
  field is annotated with BeanAlias. If so, the name of the generated
  field will be set to the value on the BeanAlias-annotation, and the
  annotation will be removed from the generated field.

Fix for issue #130

- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md

Added array-mapping

- Added BeanMapper#map(Object[], Class) allowing users to map an array
  to a new array of the given type.
- Added tests.
- Updated CHANGELOG.md

Added Queue-mapping

- Added BeanMapper#map(Queue, Class)
- Improved BeanMapperTest#mapQueueToTarget_PriorityQueue()
- Updated CHANGELOG.md

Set jackson-databind version to latest stable

Removed deprecated

- Removed BeanMapper#config().
- Removed BeanMapper#wrapConfig().
- Removed BeanMapperAware.java.
- Updated CHANGELOG.md

Converted BeanMapper from record, back to class.

Auto-reformat using MAD-style

Replaced NOPs in OverrideConfiguration with suitable Exceptions.

- OverrideConfiguration#withoutDefaultConverters throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addLogicSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addCollectionHandler throws a
  BeanConfigurationOperationNotAllowedException(String)
- OverrideConfiguration#addProxySkipClass throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(Class<?>) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(String) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addAfterClearFlusher throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setRoleSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setBeanUnproxy throws a
  BeanConfigurationOperationNotAllowedException(String).
- Updated tests.
- Updated CHANGELOG.md.

Replaced usages of Boolean-class, with primitive or enum.

- Replaced the OverrideConfiguration#flushAfterClear-Boolean with enum
  FlushAfterClearInstruction. The FlushAfterClearInstruction-enum, just
  like the Boolean-wrapper, allows for three values:
  FlushAfterClearInstruction#FLUSH_ENABLED (true),
  FlushAfterClearInstruction#FLUSH_DISABLED (false) and
  FlushAfterClearInstruction#UNSET (null). Using this enum mitigates the
  unpleasant usage of the Boolean-class, and should prevent NPEs.
- Replaced the usage of Boolean with the primitive boolean, wherever
  possible.
- Updated tests where necessary.
- Updated CHANGELOG.md

Methods that return a collection will always return a non-null object.

- Every method that returns a collection that may be null, will check
  whether the collection is null. If the collection is null, the method
  will return an empty, immutable collection of the correct type.
- Updated relevant tests to reflect that methods returning a collection
  will never return null when a collection is required.
- Updated CHANGELOG.md

Added Collection and Queue mapping

- Added BeanMapper#map(Collection, Class), allowing users to map from a
  Collection to the actual type of the Collection automatically.
- Added QueueCollectionHandler, allowing mapping of subtypes of the
  Queue-interface.

Bumped jackson-databind dependency

- Bumped the jackson-databind dependency up to version 2.14.0-rc1, due
  to a transitive vulnerability.
- Extracted plugin-versions to properties.

Updated dependencies and CHANGELOG.md
marcus-talbot42 added a commit that referenced this issue Nov 9, 2022
Process Feedback in preparation of release.

- Renamed RecordConstruct, to BeanRecordConstruct, to comply with
  naming conventions.
- Renamed RecordConstructMode, to BeanRecordConstructMode, to comply
  naming conventions.
- Replaced FlushAfterClearInstruction-enum with the more widely-usable
  Trinary-enum.
- Retouched DefaultBeanInitializer, to use BeanMapper's utility methods
  as much as possible.
- Updated CHANGELOG.md

Added arbitrarily deep Optional Mapping

- BeanMapper#map(Optional, Class) should now allow for mapping of
  Optional<Optional<?>> to a target class. Every Optional may also
  contain another Optional. The only limit is the recursion limit.
- It is now possible to automatically map Optional<X> to Optional<Y>,
due to changes in the OptionalToObjectConverter.
- Supports mapping Optional<List<X>> to Optional<List<Y>>. Same for
  Sets.
- Added mapping Optional<Map<X>> to Optional<Map<Y>>.

Fixes FieldShadowingException for ignored fields.

- Ignoring fields with BeanIgnore-annotation when detecting field
  shadowing.
- Fixed problem with getting a class using the name of an accessor.

Fix for #132

- Added BeanMatchStore#detectBeanPropertyFieldShadowing(PropertyAccessor
  , io.beanmapper.annotations.BeanProperty), which detects field
  shadowing and throws a FieldShadowingException when appropriate.

Added Mapping to and from Record-classes

- Improved the use of generics in BeanConverter, and its derived
  classes.
- Changed AbstractBeanConverter#convert, to allow the mapping of null to
  primitives, by using the default value for the relevant primitive,
  using Configuration#getDefaultValuesForClass(Class).
- Modified AbstractMapStrategy#convert, to offer null-values to
  BeanConverters.
- Added AssertionUtils to tests, containing some useful macros for
  certain tedious-to-write assertions.
- Added documentation to BeanAlias, to - hopefully - make it easier to
  understand its purpose, and map its valid use-cases.
- Improved the use of generics in the BeanMapper-class.
- Added the RecordToAnyConverter to the default converters in
  BeanMapperBuilder#addDefaultConverters().
- Added BeanMapperBuilder#addCustomDefaultValue(Class, Object), which
  allows users to set their own defaults, even allowing defaults for
  complex objects.
- Added MappingException, to create a common super-class for exceptions
  relating to bean-mapping and record-mapping.
- Replaced conditionals where an annotation is compared with null with
  usages of Class#isAnnotationPresent(Class).
- Added ClassGenerator#createClassDerivedFromRecord(Class, Set<String>),
  which dynamically creates a class based off of a Record-class, setting
  the field-modifiers to public.
- Added PropertyAccessor#isAnnotationPresent(Class), which checks
  whether the given annotation-class is present on the accessor.
- Added Configuration#addCustomDefaultValueForClass(Class, Object),
  which allows users to set default values for any type during runtime.
- Added Configuration#getDefaultValueForClass(Class), which allows the
  user to retrieve a default value mapped to a given class. This method
  will search the custom default values first, the default values in the
  DefaultValues-class second, and lastly, if no value is found, will
  return null.
- Added check to ConstructorArguments-constructor, to ensure that the
  constructorArgs-array is never null.
- Added a Map<Class, Object> to CoreConfiguration and
  OverrideConfiguration, to allow for the storing of custom default
  values.
- Modified DefaultBeanInitializer#mapParameterizedArguments, to pass a
  ParameterizedType to BeanMapper#map(Object, ParameterizedType) when
  appropriate.
- Added defaults for Optional, List, Set and Map to DefaultValues.
- Using unsupported methods in the PropertyAccessor-implementations now
  result in an UnsupportedOperationException being thrown.
- Improved usage of generics in MapStrategy and implementing classes.
- Modified MapToClassStrategy#map(Object) to let the
  RecordToAnyConverter handle a source Record.
- Added MapToRecordStrategy, which is used to map a source to a Record.
  Somewhat similar to the way a class annotated with BeanConstruct is
  mapped.
- Instances where Field#setAccessible(boolean) is called, are now
  preceded by a check to make certain that those fields are
  inaccessible.
- PrimitiveConvert will no longer throw an Exception when null is passed
  as the source to
  PrimitiveConverter#convert(BeanMapper, Object, Class,
  BeanPropertyMatch). Rather, the default value for the target-class is
  retrieved and returned.
- Added PropertyAccessors#findPropertyDescriptorsForRecord(Class), which
  compiles a Map<String, PropertyDescriptor>, based on the names of the
  RecordComponent-objects of the Record, and their accessors.
- Added RecordConstruct, which provides runtime-instructions to
  BeanMapper.
- Added RecordConstructMode, can be used to set which constructor in a
  Record should be used, or excluded, by BeanMapper, while mapping to a
  Record.
- Added RecordConstructorConflictException, which will be thrown while
  attempting to map to a record which has multiple constructors set with
  the constructMode-option set to RecordConstructMode.FORCE. Notifies
  the user of the constructors with the conflicting constructors.
- Added RecordToAnyConverter, which is used to dynamically create a
  class, based off of the source Record. The dynamically generated class
  is then used as an intermediary between the Record and the
  target-class.
- Added SourceFieldAccessException, which is thrown when the
  MapToRecordStrategy cannot access a field in the target Record.
- Replaced all instances of String#format with String#formatted.
- Removed slf4j-api dependency, as it is transitive through
  jcl-over-slf4j.
- Added tests to improve coverage.
- Updated CHANGELOG.md.

Fix for issue #168

- By catching Throwable, and saving Throwable in the List, rather than
  exception, the test should work correctly, and fail when it should.

Fix for issue #166

- Modified ClassGenerator#createClass, to check whether a generated
  field is annotated with BeanAlias. If so, the name of the generated
  field will be set to the value on the BeanAlias-annotation, and the
  annotation will be removed from the generated field.

Fix for issue #130

- Added DefaultBeanInitializer#mapParameterizedArguments(Type[],
  Object[]), allowing BeanMapper to properly map constructor parameters
  with a type-parameter, when using the @BeanConstruct-annotation.
- Using @sptdevos' tests to confirm proper functionality.
- Updated CHANGELOG.md

Added array-mapping

- Added BeanMapper#map(Object[], Class) allowing users to map an array
  to a new array of the given type.
- Added tests.
- Updated CHANGELOG.md

Added Queue-mapping

- Added BeanMapper#map(Queue, Class)
- Improved BeanMapperTest#mapQueueToTarget_PriorityQueue()
- Updated CHANGELOG.md

Set jackson-databind version to latest stable

Removed deprecated

- Removed BeanMapper#config().
- Removed BeanMapper#wrapConfig().
- Removed BeanMapperAware.java.
- Updated CHANGELOG.md

Converted BeanMapper from record, back to class.

Auto-reformat using MAD-style

Replaced NOPs in OverrideConfiguration with suitable Exceptions.

- OverrideConfiguration#withoutDefaultConverters throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addLogicSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addCollectionHandler throws a
  BeanConfigurationOperationNotAllowedException(String)
- OverrideConfiguration#addProxySkipClass throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(Class<?>) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addPackagePrefix(String) throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#addAfterClearFlusher throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setRoleSecuredCheck throws a
  BeanConfigurationOperationNotAllowedException(String).
- OverrideConfiguration#setBeanUnproxy throws a
  BeanConfigurationOperationNotAllowedException(String).
- Updated tests.
- Updated CHANGELOG.md.

Replaced usages of Boolean-class, with primitive or enum.

- Replaced the OverrideConfiguration#flushAfterClear-Boolean with enum
  FlushAfterClearInstruction. The FlushAfterClearInstruction-enum, just
  like the Boolean-wrapper, allows for three values:
  FlushAfterClearInstruction#FLUSH_ENABLED (true),
  FlushAfterClearInstruction#FLUSH_DISABLED (false) and
  FlushAfterClearInstruction#UNSET (null). Using this enum mitigates the
  unpleasant usage of the Boolean-class, and should prevent NPEs.
- Replaced the usage of Boolean with the primitive boolean, wherever
  possible.
- Updated tests where necessary.
- Updated CHANGELOG.md

Methods that return a collection will always return a non-null object.

- Every method that returns a collection that may be null, will check
  whether the collection is null. If the collection is null, the method
  will return an empty, immutable collection of the correct type.
- Updated relevant tests to reflect that methods returning a collection
  will never return null when a collection is required.
- Updated CHANGELOG.md

Added Collection and Queue mapping

- Added BeanMapper#map(Collection, Class), allowing users to map from a
  Collection to the actual type of the Collection automatically.
- Added QueueCollectionHandler, allowing mapping of subtypes of the
  Queue-interface.

Bumped jackson-databind dependency

- Bumped the jackson-databind dependency up to version 2.14.0-rc1, due
  to a transitive vulnerability.
- Extracted plugin-versions to properties.

Updated dependencies and CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix-developed A fix has been developed, and is set to be included in the coming release.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants