Skip to content

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

@mykelalvis

Description

@mykelalvis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions