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

com.cisco.trex.stateful.api.lowlevel.ASTFGlobalInfoPerTemplate Maven / Gradle / Ivy

There is a newer version: 1.69
Show newest version
package com.cisco.trex.stateful.api.lowlevel;

import com.google.gson.JsonObject;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/** Java implementation for TRex python sdk ASTFGlobalInfoPerTemplate class */
public class ASTFGlobalInfoPerTemplate implements ASTFGlobalInfoBase {
  private JsonObject tcp = new JsonObject();
  private JsonObject ip = new JsonObject();
  private JsonObject ipv6 = new JsonObject();
  private static final Set tcpParamSet =
      new HashSet<>(
          Arrays.asList(
              "initwnd", "mss", "no_delay", "rxbufsize", "txbufsize", "no_delay_counter"));

  @Override
  public ASTFGlobalInfoBase scheduler(SchedulerParam schedulerParam, int value) {
    throw new IllegalStateException("unsupported method in AstfGlobalInfoPerTemplate class");
  }

  @Override
  public ASTFGlobalInfoBase ipv6(Ipv6Param ipv6Param, int value) {
    ipv6.addProperty(ipv6Param.getType(), value);
    return this;
  }

  @Override
  public ASTFGlobalInfoBase tcp(TcpParam tcpParam, int value) {
    if (!tcpParamSet.contains(tcpParam.getType())) {
      throw new IllegalStateException(
          String.format(
              "TcpParam: %s is not support in AstfGlobalInfoPerTemplate class",
              tcpParam.getType()));
    }
    tcp.addProperty(tcpParam.getType(), value);
    return this;
  }

  @Override
  public ASTFGlobalInfoBase ip(IpParam ipParam, int value) {
    ip.addProperty(ipParam.getType(), value);
    return this;
  }

  @Override
  public JsonObject toJson() {
    JsonObject jsonObject = new JsonObject();
    if (tcp.size() != 0) {
      jsonObject.add("tcp", this.tcp);
    }
    if (ip.size() != 0) {
      jsonObject.add("ip", this.ip);
    }
    if (ipv6.size() != 0) {
      jsonObject.add("ipv6", this.ipv6);
    }
    return jsonObject;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy