@Test public void testNightPortion() throws Exception { CalculationParameters parameters = new CalculationParameters(18, 18); parameters.highLatitudeRule = HighLatitudeRule.MIDDLE_OF_THE_NIGHT; assertThat(parameters.nightPortions().fajr).isWithin(0.001).of(0.5); assertThat(parameters.nightPortions().isha).isWithin(0.001).of(0.5); parameters = new CalculationParameters(18.0, 18.0); parameters.highLatitudeRule = HighLatitudeRule.SEVENTH_OF_THE_NIGHT; assertThat(parameters.nightPortions().fajr).isWithin(0.001).of(1.0/7.0); assertThat(parameters.nightPortions().isha).isWithin(0.001).of(1.0/7.0); parameters = new CalculationParameters(10.0, 15.0); parameters.highLatitudeRule = HighLatitudeRule.TWILIGHT_ANGLE; assertThat(parameters.nightPortions().fajr).isWithin(0.001).of(10.0/60.0); assertThat(parameters.nightPortions().isha).isWithin(0.001).of(15.0/60.0); }
NightPortions nightPortions() { switch (this.highLatitudeRule) { case MIDDLE_OF_THE_NIGHT: { return new NightPortions(1.0 / 2.0, 1.0 / 2.0); } case SEVENTH_OF_THE_NIGHT: { return new NightPortions(1.0 / 7.0, 1.0 / 7.0); } case TWILIGHT_ANGLE: { return new NightPortions(this.fajrAngle / 60.0, this.ishaAngle / 60.0); } default: { throw new IllegalArgumentException("Invalid high latitude rule"); } } }
CalculationParameters { NightPortions nightPortions() { switch (this.highLatitudeRule) { case MIDDLE_OF_THE_NIGHT: { return new NightPortions(1.0 / 2.0, 1.0 / 2.0); } case SEVENTH_OF_THE_NIGHT: { return new NightPortions(1.0 / 7.0, 1.0 / 7.0); } case TWILIGHT_ANGLE: { return new NightPortions(this.fajrAngle / 60.0, this.ishaAngle / 60.0); } default: { throw new IllegalArgumentException("Invalid high latitude rule"); } } } }
CalculationParameters { NightPortions nightPortions() { switch (this.highLatitudeRule) { case MIDDLE_OF_THE_NIGHT: { return new NightPortions(1.0 / 2.0, 1.0 / 2.0); } case SEVENTH_OF_THE_NIGHT: { return new NightPortions(1.0 / 7.0, 1.0 / 7.0); } case TWILIGHT_ANGLE: { return new NightPortions(this.fajrAngle / 60.0, this.ishaAngle / 60.0); } default: { throw new IllegalArgumentException("Invalid high latitude rule"); } } } CalculationParameters(double fajrAngle, double ishaAngle);  CalculationParameters(double fajrAngle, int ishaInterval);  CalculationParameters(double fajrAngle, double ishaAngle, CalculationMethod method);  CalculationParameters(double fajrAngle, int ishaInterval, CalculationMethod method); }
CalculationParameters { NightPortions nightPortions() { switch (this.highLatitudeRule) { case MIDDLE_OF_THE_NIGHT: { return new NightPortions(1.0 / 2.0, 1.0 / 2.0); } case SEVENTH_OF_THE_NIGHT: { return new NightPortions(1.0 / 7.0, 1.0 / 7.0); } case TWILIGHT_ANGLE: { return new NightPortions(this.fajrAngle / 60.0, this.ishaAngle / 60.0); } default: { throw new IllegalArgumentException("Invalid high latitude rule"); } } } CalculationParameters(double fajrAngle, double ishaAngle);  CalculationParameters(double fajrAngle, int ishaInterval);  CalculationParameters(double fajrAngle, double ishaAngle, CalculationMethod method);  CalculationParameters(double fajrAngle, int ishaInterval, CalculationMethod method); CalculationParameters withMethodAdjustments(PrayerAdjustments adjustments); }
CalculationParameters { NightPortions nightPortions() { switch (this.highLatitudeRule) { case MIDDLE_OF_THE_NIGHT: { return new NightPortions(1.0 / 2.0, 1.0 / 2.0); } case SEVENTH_OF_THE_NIGHT: { return new NightPortions(1.0 / 7.0, 1.0 / 7.0); } case TWILIGHT_ANGLE: { return new NightPortions(this.fajrAngle / 60.0, this.ishaAngle / 60.0); } default: { throw new IllegalArgumentException("Invalid high latitude rule"); } } } CalculationParameters(double fajrAngle, double ishaAngle);  CalculationParameters(double fajrAngle, int ishaInterval);  CalculationParameters(double fajrAngle, double ishaAngle, CalculationMethod method);  CalculationParameters(double fajrAngle, int ishaInterval, CalculationMethod method); CalculationParameters withMethodAdjustments(PrayerAdjustments adjustments); public CalculationMethod method; public double fajrAngle; public double ishaAngle; public int ishaInterval; public Madhab madhab; public HighLatitudeRule highLatitudeRule; public PrayerAdjustments adjustments; public PrayerAdjustments methodAdjustments; }