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

com.neotys.neoload.model.v3.project.scenario.GsonAdaptersMonitoringParameters 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 javax.annotation.Generated;
import javax.annotation.ParametersAreNonnullByDefault;

/**
 * A {@code TypeAdapterFactory} that handles all of the immutable types generated under {@code MonitoringParameters}.
 * @see ImmutableMonitoringParameters
 */
@SuppressWarnings("all")
@Generated({"Gsons.generator", "com.neotys.neoload.model.v3.project.scenario.MonitoringParameters"})
@ParametersAreNonnullByDefault
public final class GsonAdaptersMonitoringParameters implements TypeAdapterFactory {
  @SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
  @Override
  public  TypeAdapter create(Gson gson, TypeToken type) {
    if (MonitoringParametersTypeAdapter.adapts(type)) {
      return (TypeAdapter) new MonitoringParametersTypeAdapter(gson);
    }
    return null;
  }

  @Override
  public String toString() {
    return "GsonAdaptersMonitoringParameters(MonitoringParameters)";
  }

  @SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
  private static class MonitoringParametersTypeAdapter extends TypeAdapter {
    public final Integer beforeFirstVuTypeSample = null;
    public final Integer afterLastVusTypeSample = null;
    private final TypeAdapter beforeFirstVuTypeAdapter;
    private final TypeAdapter afterLastVusTypeAdapter;

    MonitoringParametersTypeAdapter(Gson gson) {
      this.beforeFirstVuTypeAdapter = gson.getAdapter( Integer.class);
      this.afterLastVusTypeAdapter = gson.getAdapter( Integer.class);
    } 

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

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

    @Override
    public MonitoringParameters read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      return readMonitoringParameters(in);
    }

    private void writeMonitoringParameters(JsonWriter out, MonitoringParameters instance)
        throws IOException {
      out.beginObject();
      Integer beforeFirstVuValue = instance.getBeforeFirstVu();
      if (beforeFirstVuValue != null) {
        out.name("beforeFirstVu");
        beforeFirstVuTypeAdapter.write(out, beforeFirstVuValue);
      } else if (out.getSerializeNulls()) {
        out.name("beforeFirstVu");
        out.nullValue();
      }
      Integer afterLastVusValue = instance.getAfterLastVus();
      if (afterLastVusValue != null) {
        out.name("afterLastVus");
        afterLastVusTypeAdapter.write(out, afterLastVusValue);
      } else if (out.getSerializeNulls()) {
        out.name("afterLastVus");
        out.nullValue();
      }
      out.endObject();
    }

    private MonitoringParameters readMonitoringParameters(JsonReader in)
        throws IOException {
      ImmutableMonitoringParameters.Builder builder = ImmutableMonitoringParameters.builder();
      in.beginObject();
      while (in.hasNext()) {
        eachAttribute(in, builder);
      }
      in.endObject();
      return builder.build();
    }

    private void eachAttribute(JsonReader in, ImmutableMonitoringParameters.Builder builder)
        throws IOException {
      String attributeName = in.nextName();
      switch (attributeName.charAt(0)) {
      case 'b':
        if ("beforeFirstVu".equals(attributeName)) {
          readInBeforeFirstVu(in, builder);
          return;
        }
        break;
      case 'a':
        if ("afterLastVus".equals(attributeName)) {
          readInAfterLastVus(in, builder);
          return;
        }
        break;
      default:
      }
      in.skipValue();
    }

    private void readInBeforeFirstVu(JsonReader in, ImmutableMonitoringParameters.Builder builder)
        throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
      } else {
        Integer value = beforeFirstVuTypeAdapter.read(in);
        builder.beforeFirstVu(value);
      }
    }

    private void readInAfterLastVus(JsonReader in, ImmutableMonitoringParameters.Builder builder)
        throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
      } else {
        Integer value = afterLastVusTypeAdapter.read(in);
        builder.afterLastVus(value);
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy