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

SunPhase is not thread safe #14

Open
NaanProphet opened this issue Jan 6, 2018 · 0 comments
Open

SunPhase is not thread safe #14

NaanProphet opened this issue Jan 6, 2018 · 0 comments

Comments

@NaanProphet
Copy link
Contributor

NaanProphet commented Jan 6, 2018

Because of the setters on private Calendar startDate, endDate; the SunPhase class is not thread safe. And since com.florianmski.suncalc.SunCalc which calls the setters is in a different package from com.florianmski.suncalc.models.SunPhase, the setter can't even be made package private for better encapsulation.

Perhaps we SunPhase should only house the the existing constructor's final variables:

    private final Name name;
    private final double startAngle, endAngle;
    private final boolean startRise, endRise;

and then, once the date is known, we construct and return a new SunPhaseDay class once the date is specified in SunCalc#getPhases that includes:

    private final Name name;
    private final double startAngle, endAngle;
    private final boolean startRise, endRise;
    private final Calendar startDate, endDate;
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