Skip to content

Feature Request: Ability to define field visibility and turn off generating getters/setters. #864

@bpossolo

Description

@bpossolo

Is your feature request related to a problem? Please describe.
It's frustrating having to use JavaBean getter methods to access properties of generated model classes.
Also, since the model classes are often used simply for data transfer, I have no need for setters.

Describe the solution you'd like
Ability to control field visibility for generated model classes.
Ability to turn off generating getters/setters.
I'd like to generate immutable model classes with public final properties and no getters/setters.

Describe alternatives you've considered
I realize this goes against the common way in which people tend to use java.
However, I think there is a valid case for not having getters/setters on "dumb" data transfer objects.
In my client code (which is mostly presentational view layer using PlayFramework), I simply reference my model object properties as I would javascript object notation.
i.e. product.brand.name as opposed to product.getBrand().getName()
This makes my client code/templates much cleaner and easier to read.

Example ideal generated classes

public class Product {

  public final Brand brand;
  
  public Product(Brand brand) {
    this.brand = brand;
  }
}

public class Brand {

  public final String name;
  
  public Brand(String name) {
    this.name = name;
  }
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgood-first-issueGood for newcomersjavaPull requests that update Java code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions