2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.astro.internal.model;
15 import java.util.Calendar;
17 import javax.measure.quantity.Angle;
18 import javax.measure.quantity.Dimensionless;
19 import javax.measure.quantity.Time;
21 import org.openhab.core.library.types.QuantityType;
22 import org.openhab.core.library.unit.Units;
25 * Holds the calculates moon phase informations.
27 * @author Gerhard Riegler - Initial contribution
28 * @author Christoph Weitkamp - Introduced UoM
30 public class MoonPhase {
31 private Calendar firstQuarter;
32 private Calendar full;
33 private Calendar thirdQuarter;
34 private Calendar _new;
36 private double illumination;
37 private double agePercent;
38 private double ageDegree;
40 private MoonPhaseName name;
43 * Returns the date at which the moon is in the first quarter.
45 public Calendar getFirstQuarter() {
50 * Sets the date at which the moon is in the first quarter.
52 public void setFirstQuarter(Calendar firstQuarter) {
53 this.firstQuarter = firstQuarter;
57 * Returns the date of the full moon.
59 public Calendar getFull() {
64 * Sets the date of the full moon.
66 public void setFull(Calendar full) {
71 * Returns the date at which the moon is in the third quarter.
73 public Calendar getThirdQuarter() {
78 * Sets the date at which the moon is in the third quarter.
80 public void setThirdQuarter(Calendar thirdQuarter) {
81 this.thirdQuarter = thirdQuarter;
85 * Returns the date of the new moon.
87 public Calendar getNew() {
92 * Sets the date of the new moon.
94 public void setNew(Calendar _new) {
99 * Returns the age in days.
101 public QuantityType<Time> getAge() {
102 return new QuantityType<>(age, Units.DAY);
106 * Sets the age in days.
108 public void setAge(double age) {
113 * Returns the illumination.
115 public QuantityType<Dimensionless> getIllumination() {
116 return new QuantityType<>(illumination, Units.PERCENT);
120 * Sets the illumination.
122 public void setIllumination(double illumination) {
123 this.illumination = illumination;
127 * Returns the phase name.
129 public MoonPhaseName getName() {
134 * Sets the phase name.
136 public void setName(MoonPhaseName name) {
141 * Returns the age in degree.
143 public QuantityType<Angle> getAgeDegree() {
144 return new QuantityType<>(ageDegree, Units.DEGREE_ANGLE);
148 * Sets the age in degree.
150 public void setAgeDegree(double ageDegree) {
151 this.ageDegree = ageDegree;
155 * Returns the age in percent.
157 public QuantityType<Dimensionless> getAgePercent() {
158 return new QuantityType<>(agePercent, Units.PERCENT);
162 * Sets the age in percent.
164 public void setAgePercent(double agePercent) {
165 this.agePercent = agePercent;