Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for mapping records with nested records.
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
- Loading branch information