package clarifai2.dto.input;

import clarifai2.internal.JSONObjectBuilder;
import com.google.auto.value.AutoValue;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.annotations.JsonAdapter;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Type;

@SuppressWarnings("NullableProblems")
@AutoValue
@JsonAdapter(ClarifaiInputsStatus.Adapter.class)
public abstract class ClarifaiInputsStatus {

  @NotNull public abstract int processed();
  @NotNull public abstract int toProcess();
  @NotNull public abstract int errors();

  ClarifaiInputsStatus() {} // AutoValue instances only

  static class Adapter implements JsonSerializer<ClarifaiInputsStatus>, JsonDeserializer<ClarifaiInputsStatus> {

    @Override public JsonElement serialize(ClarifaiInputsStatus src, Type typeOfSrc, JsonSerializationContext context) {
      return new JSONObjectBuilder()
          .add("processed", src.processed())
          .add("to_process", src.toProcess())
          .add("errors", src.errors())
          .build();
    }

    @Override
    public ClarifaiInputsStatus deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
      final JsonObject root = json.getAsJsonObject();
      return new AutoValue_ClarifaiInputsStatus(
          root.get("errors").getAsInt(),
          root.get("to_process").getAsInt(),
          root.get("processed").getAsInt()
      );
    }
  }
}
@@ -756,16 +756,249 @@
 ors();%0A%0A
+  @AutoValue.Builder%0A  public interface Builder %7B%0A    @NotNull Builder processed(int processed);%0A    @NotNull Builder toProcess(int toProcess);%0A    @NotNull Builder errors(int errors);%0A    @NotNull ClarifaiInputsStatus build();%0A  %7D%0A%0A
   Clarif
@@ -1704,17 +1704,26 @@
 tsStatus
-(
+.Builder()
 %0A       
@@ -1717,32 +1717,43 @@
 der()%0A          
+.processed(
 root.get(%22errors
@@ -1746,22 +1746,25 @@
 ot.get(%22
-errors
+processed
 %22).getAs
@@ -1760,33 +1760,33 @@
 sed%22).getAsInt()
-,
+)
 %0A          root.
@@ -1772,32 +1772,43 @@
 nt())%0A          
+.toProcess(
 root.get(%22to_pro
@@ -1824,17 +1824,17 @@
 tAsInt()
-,
+)
 %0A       
@@ -1836,16 +1836,24 @@
         
+.errors(
 root.get
@@ -1850,33 +1850,30 @@
 s(root.get(%22
-processed
+errors
 %22).getAsInt(
@@ -1873,23 +1873,35 @@
 tAsInt()
-%0A
+)%0A  
       
+  .build(
 );%0A    %7D

Change ClarifaiInputsStatus to use AutoValue Builder