package de.otto.flummi;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;

import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;

import static java.util.function.Function.identity;

public class GsonCollectors {
    public static Collector<JsonElement, JsonArray, JsonArray> toJsonArray() {
        Supplier<JsonArray> supplier = JsonArray::new;
        BiConsumer<JsonArray, JsonElement> accumulator = JsonArray::add;
        BinaryOperator<JsonArray> combiner = (array1, array2) -> {
            array1.addAll(array2);
            return array1;
        };
        Function<JsonArray, JsonArray> f = identity();
        return Collector.of(supplier, accumulator, combiner, (Function<JsonArray, JsonArray>) f);
    }
}

@@ -711,63 +711,8 @@
  %7D;%0A
-        Function%3CJsonArray, JsonArray%3E f = identity();%0A
     
@@ -772,42 +772,18 @@
 er, 
-(Function%3CJsonArray, JsonArray%3E) f
+identity()
 );%0A 

revert changes