Comments (3)
For Java 1.5 backward compatibility you can could create an optional sub module dependency that is built with 1.6. Then in your core module you do some simple reflection like if org.modelmapper.jdk16.ContructorPropertiesStrategy
exists (which would only be true if the user included as a dependency and is using 1.6 >). If it exists you dynamically invoke the class. If it does not then its a NOOP. The Springframework I know does this in several places.
from modelmapper.
So all of my 1.6 functionality would need to go into a sub-module?
from modelmapper.
You can include the ConstructorProperties
annotation in your distribution and add the strategy. If on Java 5, users should not use the annotation or strategy. If on Java 6+, the rt.jar
will occur first in the classpath and your definition won't be evaluated by the Java compiler. If the ContructorPropertiesStrategy
is used, on the first invocation you can verify the Java version to disallow accidental use by 1.5 clients.
The above technique is the only way I know how to handle @SafeVarargs
to make Java 6 generated code lint free in Java 7.
I ran into this since jOOQ 3.1 now supports pluggable mappers. The previous mapper could match constructor arguments for immutable instances, but ModelMapper cannot. I'd prefer using ModelMapper to use projections and that jOOQ's mapper is slow by not retaining a reflection cache. For now I'm writing custom providers, but I find that a little ugly since it doesn't demotivates developers from using immutable domain models.
from modelmapper.
Related Issues (20)
- issue with record from java 14 HOT 1
- why modelMapper doesn't work to copy complex data from the same Entity? HOT 1
- ModelMapper cannot map all fields when mapping from proxy class over interface HOT 1
- ModelMapper mapping is updating table primary key instead of foreign key. HOT 1
- Error mapping, then reboot, works for a while
- How to skip not loaded Lazy fields?
- Test fails after upgrading from 3.1.0 to 3.1.1
- Java 21 support HOT 18
- Support of Java Module System
- Custom mapping in nested objects HOT 4
- Skip field of generic class HOT 1
- Mapping Source object to Destination object
- Mapping nested generic object with generic HOT 1
- Use specific converter for one field
- Model Mapper does not map values correctly (Intermittent - once in a few tries)
- Model Mapper Low performance
- Jackson Module: @JsonTypeInfo support for automatically handling inheritance HOT 1
- ModelMapper fails to map nested entity user field HOT 1
- When condition does not work for null-field
- How to ignore mapping errors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modelmapper.