Git Product home page Git Product logo

Comments (3)

agentgt avatar agentgt commented on July 22, 2024

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.

jhalterman avatar jhalterman commented on July 22, 2024

So all of my 1.6 functionality would need to go into a sub-module?

from modelmapper.

ben-manes avatar ben-manes commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.