Skip to content

Commit d439bcd

Browse files
committed
Improve API-docs
1 parent fe6a1c0 commit d439bcd

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

src/main/java/de/meggsimum/w3w/Coordinates.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
11
package de.meggsimum.w3w;
22

3+
/**
4+
* Class represents a position object holding its coordinates (lat/lon).
5+
*/
36
public class Coordinates {
7+
8+
/** latitude of this coordinate */
49
private double latitude;
10+
11+
/** longitude of this coordinate */
512
private double longitude;
613

14+
/**
15+
* Creates an empty {@linkplain Coordinates} object
16+
*
17+
* @param latitude
18+
* @param longitude
19+
*/
720
public Coordinates() {
821
}
922

23+
/**
24+
* Creates a {@linkplain Coordinates} object with the given latitude and
25+
* longitude
26+
*
27+
* @param latitude
28+
* @param longitude
29+
*/
1030
public Coordinates(double latitude, double longitude) {
1131
this.latitude = latitude;
1232
this.longitude = longitude;
1333
}
1434

35+
/**
36+
* @return latitude
37+
*/
1538
public double getLatitude() {
1639
return latitude;
1740
}
1841

42+
/**
43+
* @return longitude
44+
*/
1945
public double getLongitude() {
2046
return longitude;
2147
}

src/main/java/de/meggsimum/w3w/ThreeWords.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,76 @@
11
package de.meggsimum.w3w;
22

3+
/**
4+
* Class represents a "w3w-address" object holding the corresponding three
5+
* words.
6+
*/
37
public class ThreeWords {
8+
9+
/** the first word of this "w3w-address" */
410
private String first;
11+
12+
/** the first word of this "w3w-address" */
513
private String second;
14+
15+
/** the first word of this "w3w-address" */
616
private String third;
717

18+
/**
19+
* Creates an empty {@linkplain ThreeWords} object.
20+
*/
821
public ThreeWords() {
922
}
1023

24+
/**
25+
* Creates a {@linkplain ThreeWords} object with the given three words.
26+
*/
1127
public ThreeWords(String first, String second, String third) {
1228
this.first = first;
1329
this.second = second;
1430
this.third = third;
1531
}
1632

33+
/**
34+
* @return first word of this "w3w-address"
35+
*/
1736
public String getFirst() {
1837
return first;
1938
}
2039

40+
/**
41+
* @param first
42+
* the first word of this "w3w-address" to set
43+
*/
2144
public void setFirst(String first) {
2245
this.first = first;
2346
}
2447

48+
/**
49+
* @return second word of this "w3w-address"
50+
*/
2551
public String getSecond() {
2652
return second;
2753
}
2854

55+
/**
56+
* @param second
57+
* the second word of this "w3w-address" to set
58+
*/
2959
public void setSecond(String second) {
3060
this.second = second;
3161
}
3262

63+
/**
64+
* @return third word of this "w3w-address"
65+
*/
3366
public String getThird() {
3467
return third;
3568
}
3669

70+
/**
71+
* @param third
72+
* the third word of this "w3w-address" to set
73+
*/
3774
public void setThird(String third) {
3875
this.third = third;
3976
}

src/main/java/de/meggsimum/w3w/What3Words.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,41 @@ public What3Words(String apiKey) {
5050
* given language.
5151
*
5252
* @param apiKey
53-
* @param language default Language
53+
* @param language
54+
* default Language
5455
*/
5556
public What3Words(String apiKey, String language) {
5657
this.apiKey = apiKey;
5758
this.language = language;
5859
}
5960

61+
/**
62+
* Converts 3 words object (in the given language) into a position object.
63+
*
64+
* @param threeWords
65+
* "w3w-address" object in the given language
66+
* @param language
67+
* string defining the language of the words (e.g. "de")
68+
* @return coordinates object holding the coordinates reprsenting the given
69+
* words
70+
* @throws IOException
71+
* @throws What3WordsException
72+
*/
6073
public Coordinates wordsToPosition(ThreeWords threeWords, String language) throws IOException, What3WordsException {
6174
double[] doubleCoordinates = wordsToPosition(new String[]{threeWords.getFirst(), threeWords.getSecond(), threeWords.getThird()});
6275
return new Coordinates(doubleCoordinates[0], doubleCoordinates[1]);
6376
}
6477

78+
/**
79+
* Converts 3 words object into a position object.
80+
*
81+
* @param threeWords
82+
* "w3w-address" object in the given language
83+
* @return coordinates object holding the coordinates reprsenting the given
84+
* words
85+
* @throws IOException
86+
* @throws What3WordsException
87+
*/
6588
public Coordinates wordsToPosition(ThreeWords threeWords) throws IOException, What3WordsException {
6689
return wordsToPosition(threeWords, this.language);
6790
}
@@ -123,11 +146,30 @@ public double[] wordsToPosition(String[] words, String language) throws IOExcept
123146

124147
}
125148

149+
/**
150+
* Converts a position object into a "w3w-address" object (in the given
151+
* language)
152+
*
153+
* @param position object holding the coordinates to be transformed
154+
* @param language string defining the language of the words (e.g. "de")
155+
* @return "w3w-address" object in the given language
156+
* @throws IOException
157+
* @throws What3WordsException
158+
*/
126159
public ThreeWords positionToWords(Coordinates coordinates, String language) throws IOException, What3WordsException {
127160
String[] words = positionToWords(new double[]{coordinates.getLatitude(), coordinates.getLongitude()}, language);
128161
return new ThreeWords(words[0], words[1], words[2]);
129162
}
130163

164+
/**
165+
* Converts a position object into a "w3w-address" object with default
166+
* language.
167+
*
168+
* @param position object holding the coordinates to be transformed
169+
* @return "w3w-address" object
170+
* @throws IOException
171+
* @throws What3WordsException
172+
*/
131173
public ThreeWords positionToWords(Coordinates coordinates) throws IOException, What3WordsException {
132174
return positionToWords(coordinates, this.language);
133175
}

0 commit comments

Comments
 (0)