documentation home

Field Visibility

Miredot shows the structure of the return and input types. The structure is based on reflection on fields, getters and setters. Whether or not to include private fields and methods in the resulting data objects, depends on the @JsonAutoDetect annotation. However, some (de)serialisation frameworks are globally configurable to change the default visibility. For example, in Jackson, this is done by setting the ObjectMapper visibility to choose what to include. Miredot cannot deduce this from the interface definitions, but the defaults can be configured via your project pom.xml.

This is done by adding the <fieldVisibility> tag under the RestModel section in the Miredot plugin configuration. Under this tag, you can specify the visibility for each type of accessor in the form of <ACCESSOR>VISIBILITY</ACCESSOR> where

  • ACCESSOR can be GETTER, IS_GETTER, SETTER, CREATOR, FIELD or ALL (to set a value for all accessor types) and
  • VISIBILITY can be ANY, NON_PRIVATE, PROTECTED_AND_PUBLIC, PUBLIC_ONLY, NONE, DEFAULT.

For example, use this configuration to include all properties from non private accessors and from all (including private) fields in the structure of the return and input types.

Maven
<configuration>
    <restModel>
        <fieldVisibility>
            <ALL>NON_PRIVATE</ALL>
            <FIELD>ANY</FIELD>
        </fieldVisibility>
    </restModel>
</configuration>
Gradle
miredot {
    restModel {
       fieldVisibility = [
            ALL: 'NON_PRIVATE'
       ]
    }
}

The default values are:

Maven
<configuration>
    <restModel>
        <fieldVisibility>
            <GETTER>PUBLIC_ONLY</GETTER>
            <IS_GETTER>PUBLIC_ONLY</IS_GETTER>
            <SETTER>NON_PRIVATE</SETTER>
            <CREATOR>PUBLIC_ONLY</CREATOR>
            <FIELD>PUBLIC_ONLY</FIELD>
        </fieldVisibility>
    </restModel>
</configuration>
Gradle
miredot {
    restModel {
       fieldVisibility = [
            GETTER: 'PUBLIC_ONLY', 
            IS_GETTER: 'PUBLIC_ONLY',
            SETTER : 'NON_PRIVATE',
            CREATOR : 'PUBLIC_ONLY',
            FIELD : 'PUBLIC_ONLY' ]
    }
}