Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow writing of a model with fields that have java.getter = "false" #34

Open
mykelalvis opened this issue Jan 1, 2020 · 1 comment

Comments

@mykelalvis
Copy link
Contributor

mykelalvis commented Jan 1, 2020

I have been unable to figure out a way to produce a writer that allows the production of a writer for fields that do not have a getter.

The use case here is that I have an interface

interface ITtype {
  Optional<String> getId();
}

and a model with that has a class that implements ITtype (assume there's an <interface> node in the model, please)

        <field java.getter = "false">
          <name>id</name>
          <version>1.0.0+</version>
          <required>true</required>
          <description>An id</description>
          <type>String</type>
        </field>

and a <codeSegment> that says (approximately)

  <code>
 java.util.Optional<String> getId() { return java.util.Optional.ofNullable(this.id);}
</code>

However, the Xpp3 writer distinctly uses the getter for getId()in the writeX( code, even though that getter doesn't exist.

It seems reasonable to make the the generator for the writer produce a reflection-based get rather than trying to use a getter that is obviously not going to exist, given the the Maven/Codehaus team's comfort with using reflection to acquire the values of locally classed private fields, especially in generated code.

@mykelalvis
Copy link
Contributor Author

Would it be a possibility for me to extend the Xpp3 writer plugin that does this or do there be dragons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant