0.1.2
New Feature
Start to support the population for inherited fields of derived classes. (#3)
Demonstration
Assume we have Base
and Derived
classes like below:
class Base {
public int baseInt;
public String name; // hidden field
public Instant time; // hidden field
}
class Derived {
public int derivedInt;
public long derivedLong;
public String name; // hides base class field
public Date time; // hides base class field
}
When we create instances of the Derived
class with DerivedModeler
, it will populate all the fields declared in Base
and Derived
classes, including hidden fields like Base#name
and Base#time
.
@Modeler(type = Derived.class) class ModelHelper {}
Derived o = DerivedModeler.next();
assert o.baseInt != null;
assert ((Base) o).name != null;
assert ((Base) o).time != null;
assert o.derivedInt != null;
assert o.derivedLong != null;
assert ((Derived) o).name != null;
assert ((Derived) o).time != null;
Hidden fields are not supported by generated Builders
Please note that the hidden fields could not be customized via the builder provided by easymodeling, for example:
Derived o = DerivedModeler.builder().name("some name").time(Instant.EPOCH).build();
assert ((Base) o).name != "some name";
assert ((Derived) o).name == "some name";
assert ((Base) o).time != Instant.EPOCH;
assert ((Derived) o).time == Instant.EPOCH;