Giter Club home page Giter Club logo

Comments (9)

schuettec avatar schuettec commented on June 26, 2024

Thank for your idea.
Can you give me a short example of what you want to do?
Just to get the use-case right.

My first guess would be, that the complexity for this feature might be high because if you want to chain setters, you have to have a valid instance of the source object available to invoke the setter on. The source object is generated later than the field-by-field mappings and currently there is no order defined on mappings.

from remap.

djarnis73 avatar djarnis73 commented on June 26, 2024

By chained setters I mean setter that return this like:

class B {
  int i;

  B setI(int i) {
    this.i = i;
    return this;
  }
}

So my proposal is to relax the pure java beans requirement for setters (either globally or it could be a mapper configuration).

from remap.

schuettec avatar schuettec commented on June 26, 2024

Ah okay, so if your idea is to relax the validation of set-methods to support chained setters I would welcome a PR :)

Sounds very reasonable to support this.

from remap.

djarnis73 avatar djarnis73 commented on June 26, 2024

I did a bit of research and debugging and I don't think there is a simple way to achieve this, since the bean introspection does not allow for chained/fluent setters.

It used to back in java 1.6.

So to implement this, we will either have to use a different introspection engine (extra external dependency), commons-beantutils seems to have one or write our own.

I will dig a bit deeper into this. One option could also be to generate two artifacts remap & remap-fluent where the -fluent has the extra dependency. But that would be at the cost of extra complexity in both code and build setup.

from remap.

djarnis73 avatar djarnis73 commented on June 26, 2024

I have made a proof of concept commit here: djarnis73@bcd99c8 please have a look and let me know if you like it.

from remap.

schuettec avatar schuettec commented on June 26, 2024

Hi, very cool that you managed to do it!
That does not look that complicated. Good idea!

I would like to integrate your PR. I would check backwards compatibility with our code base an then we go for a release :)

from remap.

schuettec avatar schuettec commented on June 26, 2024

Ah! One more thing. ReMap has an API for testing. Can you verify with a test, that the Assert API works well with your extension?

from remap.

djarnis73 avatar djarnis73 commented on June 26, 2024

How time flies, looks like I got distracted and never followed up on this. Are you still interested in getting this in? Then I will brush if off and submit a PR.

from remap.

schuettec avatar schuettec commented on June 26, 2024

Hey it's been a while :) I think it's a nice idea to support fluent setters. As you mentioned above, keep in mind, that you need another bean introspection service. Feel free to build a PR. Then we can figure out how to integrate this into remap :)

from remap.

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.