Simplify getAsTuple

This commit is contained in:
kageru 2020-07-05 21:33:51 +02:00
parent 8c9348700a
commit 9f8e7dcc1a
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

@ -145,9 +145,7 @@ public class Nouritsu extends NanoHTTPD {
// Get k1 and k2 as a tuple in Either.Right or Either.Left if k1 or k2 is/are not in the map. // Get k1 and k2 as a tuple in Either.Right or Either.Left if k1 or k2 is/are not in the map.
private static Either<Resp, Tuple2<String, String>> getAsTuple(Map<String, String> params, String k1, String k2) { private static Either<Resp, Tuple2<String, String>> getAsTuple(Map<String, String> params, String k1, String k2) {
return getFromParams(params, k1) return zip(getFromParams(params, k1), getFromParams(params, k2));
.map(Tuple::of)
.flatMap(name -> getFromParams(params, k2).map(name::append));
} }
public static void main(String[] args) { public static void main(String[] args) {