Skip to content

Commit 1693169

Browse files
committed
added java doc
1 parent 1319657 commit 1693169

18 files changed

+1443
-2
lines changed

src/main/java/io/ipgeolocation/api/Astronomy.java

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import java.math.BigDecimal;
66
import java.util.Objects;
77

8+
/**
9+
* The Astronomy class represents astronomical data for a specific date and location, including information
10+
* about sunrise, sunset, moonrise, moonset, sun and moon positions, and other related details.
11+
*
12+
* <p>The Astronomy class provides methods to access the information stored in the {@code Astronomy} object,
13+
* For Example, you can get the sunrise time by calling {@link Astronomy#getSunrise()}.
14+
*/
815
public class Astronomy {
916
private final String date;
1017
private final String currentTime;
@@ -26,6 +33,12 @@ public class Astronomy {
2633
private AstronomyLocation location;
2734
private final JSONObject json;
2835

36+
/**
37+
* Constructs an Astronomy object based on the provided JSON data.
38+
*
39+
* @param json the JSON object containing astronomical data
40+
* @throws IllegalArgumentException if the provided JSON object is null or empty
41+
*/
2942
Astronomy(JSONObject json) {
3043
if (Objects.isNull(json)) {
3144
throw new IllegalArgumentException("'json' must not be null");
@@ -59,78 +72,173 @@ public class Astronomy {
5972
this.json = json;
6073
}
6174

75+
/**
76+
* Returns the date for which astronomical data is provided.
77+
*
78+
* @return The date as String.
79+
*/
6280
public String getDate() {
6381
return date;
6482
}
6583

84+
/**
85+
* Returns the current time at the location in the format "HH:mm:ss".
86+
*
87+
* @return The current time as String.
88+
*/
6689
public String getCurrentTime() {
6790
return currentTime;
6891
}
6992

93+
/**
94+
* Returns the time of sunrise in the format "HH:mm".
95+
*
96+
* @return The time of sunrise as String.
97+
*/
7098
public String getSunrise() {
7199
return sunrise;
72100
}
73101

102+
/**
103+
* Returns the time of sunset in the format "HH:mm".
104+
*
105+
* @return The time of sunset as String.
106+
*/
74107
public String getSunset() {
75108
return sunset;
76109
}
77110

111+
/**
112+
* Returns the status of sunrise and sunset as "-", if these values are not available.
113+
*
114+
* @return The status of the sun.
115+
*/
78116
public String getSunStatus() {
79117
return sunStatus;
80118
}
81119

120+
/**
121+
* Returns the time of solar noon in the format "HH:mm".
122+
*
123+
* @return The time of solar noon as String.
124+
*/
82125
public String getSolarNoon() {
83126
return solarNoon;
84127
}
85128

129+
/**
130+
* Returns the duration of daylight in the format "HH:mm".
131+
*
132+
* @return The duration of daylight.
133+
*/
86134
public String getDayLength() {
87135
return dayLength;
88136
}
89137

138+
/**
139+
* Returns the altitude of the sun.
140+
*
141+
* @return The altitude of the sun in degrees.
142+
*/
90143
public BigDecimal getSunAltitude() {
91144
return sunAltitude;
92145
}
93146

147+
/**
148+
* Returns the distance to the sun.
149+
*
150+
* @return The distance to the sun in km.
151+
*/
94152
public BigDecimal getSunDistance() {
95153
return sunDistance;
96154
}
97155

156+
/**
157+
* Returns the azimuth of the sun.
158+
*
159+
* @return The azimuth of the sun in degrees.
160+
*/
98161
public BigDecimal getSunAzimuth() {
99162
return sunAzimuth;
100163
}
101164

165+
/**
166+
* Returns the time of moonrise in the format "HH:mm".
167+
*
168+
* @return The time of moonrise.
169+
*/
102170
public String getMoonrise() {
103171
return moonrise;
104172
}
105173

174+
/**
175+
* Returns the time of moonset in the format "HH:mm".
176+
*
177+
* @return The time of moonset.
178+
*/
106179
public String getMoonset() {
107180
return moonset;
108181
}
109182

183+
/**
184+
* Returns the status of moon rise and moon set as "-", if these values are not available.
185+
*
186+
* @return The status of the moon.
187+
*/
110188
public String getMoonStatus() {
111189
return moonStatus;
112190
}
113191

192+
/**
193+
* Returns the altitude of the moon.
194+
*
195+
* @return The altitude of the moon in degrees.
196+
*/
114197
public BigDecimal getMoonAltitude() {
115198
return moonAltitude;
116199
}
117200

201+
/**
202+
* Returns the distance to the moon.
203+
*
204+
* @return The distance to the moon in km.
205+
*/
118206
public BigDecimal getMoonDistance() {
119207
return moonDistance;
120208
}
121209

210+
/**
211+
* Returns the azimuth of the moon.
212+
*
213+
* @return The azimuth of the moon in degrees.
214+
*/
122215
public BigDecimal getMoonAzimuth() {
123216
return moonAzimuth;
124217
}
125218

219+
/**
220+
* Returns the parallactic angle of the moon.
221+
*
222+
* @return The parallactic angle of the moon in degrees.
223+
*/
126224
public BigDecimal getMoonParallacticAngle() {
127225
return moonParallacticAngle;
128226
}
129227

228+
/**
229+
* Returns the location associated with the astronomical data.
230+
*
231+
* @return The {@code AstronomyLocation} object.
232+
*/
130233
public AstronomyLocation getLocation() {
131234
return location;
132235
}
133236

237+
/**
238+
* Returns a string representation of the Astronomy object, in JSON format.
239+
*
240+
* @return A JSON string representing the astronomical data.
241+
*/
134242
@Override
135243
public String toString() {
136244
return json.toString(2);

src/main/java/io/ipgeolocation/api/AstronomyLocation.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
import java.math.BigDecimal;
66
import java.util.Objects;
77

8+
/**
9+
* The AstronomyLocation class represents geographic location data associated with astronomical information,
10+
* including latitude, longitude, country, state/province, city, and other details.
11+
*
12+
* <p>The AstronomyLocation class provides methods to access the information about the {@code AstronomyLocation} object.
13+
* For example, you can get the city name using the {@link AstronomyLocation#getCity()} method.
14+
*
15+
*/
816
public class AstronomyLocation {
917
private final String location;
1018
private final BigDecimal latitude;
@@ -21,6 +29,12 @@ public class AstronomyLocation {
2129
private final String city;
2230
private final JSONObject json;
2331

32+
/**
33+
* Constructs an AstronomyLocation object based on the provided JSON data.
34+
*
35+
* @param json the JSON object containing location data
36+
* @throws IllegalArgumentException if the provided JSON object is null or empty
37+
*/
2438
AstronomyLocation(JSONObject json) {
2539
if (Objects.isNull(json)) {
2640
throw new IllegalArgumentException("'json' must not be null");
@@ -46,58 +60,128 @@ public class AstronomyLocation {
4660
this.json = json;
4761
}
4862

63+
/**
64+
* Returns the location name (i.e., city, country) for which astronomy information queried.
65+
*
66+
* @return The location name as String.
67+
*/
4968
public String getLocation() {
5069
return location;
5170
}
5271

72+
/**
73+
* Returns the latitude coordinate.
74+
*
75+
* @return The latitude coordinate as BigDecimal.
76+
*/
5377
public BigDecimal getLatitude() {
5478
return latitude;
5579
}
5680

81+
/**
82+
* Returns the longitude coordinate.
83+
*
84+
* @return The longitude coordinate as BigDecimal.
85+
*/
5786
public BigDecimal getLongitude() {
5887
return longitude;
5988
}
6089

90+
/**
91+
* Returns the postal code/Zip code.
92+
*
93+
* @return The postal code/Zip code as String.
94+
*/
6195
public String getZipcode() {
6296
return zipcode;
6397
}
6498

99+
/**
100+
* Returns the ISO 3166-1 alpha-2 country code. e.g., 'PK' for Pakistan.
101+
*
102+
* @return The ISO 3166-1 alpha-2 country code as String.
103+
*/
65104
public String getCountryCode2() {
66105
return countryCode2;
67106
}
68107

108+
/**
109+
* Returns the ISO 3166-1 alpha-3 country code. e.g., 'PAK' for Pakistan.
110+
*
111+
* @return The ISO 3166-1 alpha-3 country code as String.
112+
*/
69113
public String getCountryCode3() {
70114
return countryCode3;
71115
}
72116

117+
/**
118+
* Returns the general country name.
119+
*
120+
* @return The country name as String.
121+
*/
73122
public String getCountryName() {
74123
return countryName;
75124
}
76125

126+
/**
127+
* Returns the official country name.
128+
*
129+
* @return The official country name as String.
130+
*/
77131
public String getCountryNameOfficial() {
78132
return countryNameOfficial;
79133
}
80134

135+
/**
136+
* Returns the state or province or region name.
137+
*
138+
* @return The state or province name as String.
139+
*/
81140
public String getStateProv() {
82141
return stateProv;
83142
}
84143

144+
/**
145+
* Returns the state or province code. e.g., 'PK-PB'
146+
*
147+
* @return The state or province code as String.
148+
*/
85149
public String getStateCode() {
86150
return stateCode;
87151
}
88152

153+
/**
154+
* Returns the district name.
155+
*
156+
* @return The district name.
157+
*/
89158
public String getDistrict() {
90159
return district;
91160
}
92161

162+
/**
163+
* Returns the locality.
164+
*
165+
* @return The locality as String.
166+
*/
93167
public String getLocality() {
94168
return locality;
95169
}
96170

171+
/**
172+
* Returns the city.
173+
*
174+
* @return The city as String.
175+
*/
97176
public String getCity() {
98177
return city;
99178
}
100179

180+
/**
181+
* Returns a string representation of the {@code AstronomyLocation} object, in JSON format.
182+
*
183+
* @return A JSON string representing the location data.
184+
*/
101185
@Override
102186
public String toString() {
103187
return json.toString(2);

0 commit comments

Comments
 (0)