Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using parameter type if setter is used #469

Open
kevits opened this issue Jan 29, 2022 · 0 comments
Open

Using parameter type if setter is used #469

kevits opened this issue Jan 29, 2022 · 0 comments

Comments

@kevits
Copy link

kevits commented Jan 29, 2022

EasyRandom uses the setter if bypassSetters=false but only when the the Randomizer supports this type (see FieldPopulator.populateField). But now I have the following situation: My type is not supported (ObjectProperty<>) but the parameter type (LocalTime) of the corresponding setter is supported. Even that EasyRandom supports LocalTime it is not possible to generate an object.

public class Time {
    private ObjectProperty<LocalTime> time;

    public LocalTime getTime() {
        return timeProperty().get();
    }

    public ObjectProperty<LocalTime> timeProperty() {
        if (time == null)
            time = new SimpleObjectProperty<>();
        return time;
    }

    public void setTime(LocalTime time) {
        timeProperty().set(time);
    }
}

In my optinon following steps would be better:

  1. If field has setter and bypassSetters=false: Take parameter type of setter
    1.1 If parameter type is not supported then throw error
  2. If field has no setter: Take field type

Any thoughts on this issue? If desired I could look into it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant