All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.neotys.neoload.model.v3.project.scenario.GsonAdaptersApm Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.project.scenario;

import com.google.gson.*;
import com.google.gson.reflect.*;
import com.google.gson.stream.*;
import java.io.IOException;
import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.processing.Generated;

/**
 * A {@code TypeAdapterFactory} that handles all of the immutable types generated under {@code Apm}.
 * @see ImmutableApm
 */
@SuppressWarnings({"all", "MethodCanBeStatic"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@org.immutables.value.Generated(from = "com.neotys.neoload.model.v3.project.scenario", generator = "Gsons")
public final class GsonAdaptersApm implements TypeAdapterFactory {
  @SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
  @Override
  public  TypeAdapter create(Gson gson, TypeToken type) {
    if (ApmTypeAdapter.adapts(type)) {
      return (TypeAdapter) new ApmTypeAdapter(gson);
    }
    return null;
  }

  @Override
  public String toString() {
    return "GsonAdaptersApm(Apm)";
  }

  @org.immutables.value.Generated(from = "Apm", generator = "Gsons")
  @SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
  private static class ApmTypeAdapter extends TypeAdapter {
    public final DynatraceAnomalyRule dynatraceAnomalyRulesTypeSample = null;
    private final TypeAdapter dynatraceAnomalyRulesTypeAdapter;

    ApmTypeAdapter(Gson gson) {
      this.dynatraceAnomalyRulesTypeAdapter = gson.getAdapter( DynatraceAnomalyRule.class);
    } 

    static boolean adapts(TypeToken type) {
      return Apm.class == type.getRawType()
          || ImmutableApm.class == type.getRawType();
    }

    @Override
    public void write(JsonWriter out, Apm value) throws IOException {
      if (value == null) {
        out.nullValue();
      } else {
        writeApm(out, value);
      }
    }

    @Override
    public Apm read(JsonReader in) throws IOException {
      return readApm(in);
    }

    private void writeApm(JsonWriter out, Apm instance)
        throws IOException {
      out.beginObject();
      List dynatraceTagsElements = instance.getDynatraceTags();
      out.name("dynatraceTags");
      out.beginArray();
      for (String e : dynatraceTagsElements) {
        out.value(e);
      }
      out.endArray();
      List dynatraceAnomalyRulesElements = instance.getDynatraceAnomalyRules();
      out.name("dynatraceAnomalyRules");
      out.beginArray();
      for (DynatraceAnomalyRule e : dynatraceAnomalyRulesElements) {
        dynatraceAnomalyRulesTypeAdapter.write(out, e);
      }
      out.endArray();
      out.endObject();
    }

    private  Apm readApm(JsonReader in)
        throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      Apm.Builder builder = new Apm.Builder();
      in.beginObject();
      while (in.hasNext()) {
        eachAttribute(in, builder);
      }
      in.endObject();
      return builder.build();
    }

    private void eachAttribute(JsonReader in, Apm.Builder builder)
        throws IOException {
      String attributeName = in.nextName();
      switch (attributeName.charAt(0)) {
      case 'd':
        if ("dynatraceTags".equals(attributeName)) {
          readInDynatraceTags(in, builder);
          return;
        }
        if ("dynatraceAnomalyRules".equals(attributeName)) {
          readInDynatraceAnomalyRules(in, builder);
          return;
        }
        break;
      default:
      }
      in.skipValue();
    }

    private void readInDynatraceTags(JsonReader in, Apm.Builder builder)
        throws IOException {
      if (in.peek() == JsonToken.BEGIN_ARRAY) {
        in.beginArray();
        while(in.hasNext()) {
          builder.addDynatraceTags(in.nextString());
        }
        in.endArray();
      } else if (in.peek() == JsonToken.NULL) {
        in.nextNull();
      } else {
        builder.addDynatraceTags(in.nextString());
      }
    }

    private void readInDynatraceAnomalyRules(JsonReader in, Apm.Builder builder)
        throws IOException {
      if (in.peek() == JsonToken.BEGIN_ARRAY) {
        in.beginArray();
        while(in.hasNext()) {
          DynatraceAnomalyRule value = dynatraceAnomalyRulesTypeAdapter.read(in);
          builder.addDynatraceAnomalyRules(value);
        }
        in.endArray();
      } else if (in.peek() == JsonToken.NULL) {
        in.nextNull();
      } else {
        DynatraceAnomalyRule value = dynatraceAnomalyRulesTypeAdapter.read(in);
        builder.addDynatraceAnomalyRules(value);
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy