Skip to content

Commit

Permalink
Fix for issue with DynamicClassGeneratorHelper#getNeighbourClass(CtCl…
Browse files Browse the repository at this point in the history
…ass)

- DynamicClassGeneratorHelper#getNeighbourClass(CtClass) would return
  null on some occasions. This was fixed by passing the base-class for
  the dynamic class to the constructor of GeneratedClass. The baseclass
  can be used as a substitute for the neighbour-class.
- Updated CHANGELOG.md.
  • Loading branch information
marcus-talbot42 committed Sep 20, 2022
1 parent 74fde61 commit f07f8a3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 77 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Issue [#137](https://github.com/42BV/beanmapper/issues/137) **https://github.com/42BV/beanmapper/issues/137**; Mapping a class with a getter that returns an
Optional, would fail, as an Optional can typically not be mapped to the target class. Fixed implementing an OptionalToObjectConverter, which handles unpacking
an Optional, and additionally delegates further conversion back to the BeanMapper.
- DynamicClassGeneratorHelper was removed, due to returning null, and replaced with passing the baseclass for a generated class immediately to the constructor
of GeneratedClass.


## [3.2.0] - 2022-09-15
## [4.0.0] - 2022-09-15

### Changed

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/beanmapper/dynclass/ClassGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public GeneratedClass createClass(
Map<String, BeanProperty> baseFields = beanMatchStore.getBeanMatch(
strictMappingProperties.createBeanPair(baseClass, Object.class)
).getSourceNodes();
return new GeneratedClass(createClass(baseClass, baseFields, displayNodes, strictMappingProperties));
return new GeneratedClass(createClass(baseClass, baseFields, displayNodes, strictMappingProperties), baseClass);
}

private synchronized CtClass createClass(
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/io/beanmapper/dynclass/GeneratedClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class GeneratedClass {

public final Class<?> generatedClass;

public GeneratedClass(CtClass ctClass) throws CannotCompileException {
public GeneratedClass(CtClass ctClass, Class<?> baseClass) throws CannotCompileException {
this.ctClass = ctClass;
this.generatedClass = ctClass.toClass(DynamicClassGeneratorHelper.getNeighbourClass(ctClass));
this.generatedClass = ctClass.toClass(baseClass);
}

}

This file was deleted.

0 comments on commit f07f8a3

Please sign in to comment.