Skip to content

Commit dfdd24f

Browse files
committed
Fix optional usage in AndroidGeoLocation builder
1 parent 7806c7d commit dfdd24f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/io/appium/java_client/android/geolocation/AndroidGeoLocation.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Collections;
2020
import java.util.HashMap;
2121
import java.util.Map;
22+
import java.util.Optional;
2223

2324
import static java.util.Optional.ofNullable;
2425

@@ -39,7 +40,7 @@ public AndroidGeoLocation() {
3940
/**
4041
* Initializes AndroidLocation instance with longitude and latitude values.
4142
*
42-
* @param latitude latitude value
43+
* @param latitude latitude value
4344
* @param longitude longitude value
4445
*/
4546
public AndroidGeoLocation(double latitude, double longitude) {
@@ -111,10 +112,10 @@ public AndroidGeoLocation withSpeed(double speed) {
111112
*/
112113
public Map<String, ?> build() {
113114
var map = new HashMap<String, Object>();
114-
ofNullable(longitude).map(x -> map.put("longitude", x)).orElseThrow(() -> new IllegalArgumentException(
115-
"A valid 'longitude' must be provided"));
116-
ofNullable(latitude).map(x -> map.put("latitude", x)).orElseThrow(() -> new IllegalArgumentException(
117-
"A valid 'latitude' must be provided"));
115+
map.put("longitude", ofNullable(longitude).orElseThrow(() -> new IllegalArgumentException(
116+
"A valid 'longitude' must be provided")));
117+
map.put("latitude", ofNullable(latitude).orElseThrow(() -> new IllegalArgumentException(
118+
"A valid 'latitude' must be provided")));
118119
ofNullable(altitude).ifPresent(x -> map.put("altitude", x));
119120
ofNullable(satellites).ifPresent(x -> map.put("satellites", x));
120121
ofNullable(speed).ifPresent(x -> map.put("speed", x));

0 commit comments

Comments
 (0)