stephenh / dtonator

code generator for creating DTOs and mapping to domain objects
Other
14 stars 5 forks source link

Expected Behavior for Getters With No Field #10

Open pbtura opened 7 years ago

pbtura commented 7 years ago

Currently, dto properties will be generated for all methods that follow the T getX() or setX(T t) pattern. This includes 'generator' methods where the property does not correspond to and field of the domain class. For example, given the class

public class Brother {
  public Long id;
  public String getGender() {
    return "male";
  }
}

the generated DTO will have two properties;

Long id

and

String gender

.

In a simple case like this the behavior is harmless. It becomes a problem however if the domain getter performs an expensive operation like a database query. There is also the potential for conflicts with mapping references as Ids.

Is this the expected behavior, and if so would it be worthwhile to have a config setting to allow the user to include/exclude these properties?