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

us.abstracta.jmeter.javadsl.codegeneration.params.FixedParam Maven / Gradle / Ivy

Go to download

Simple API to run JMeter performance tests in an VCS and programmers friendly way.

There is a newer version: 028
Show newest version
package us.abstracta.jmeter.javadsl.codegeneration.params;

import java.util.function.Function;
import us.abstracta.jmeter.javadsl.codegeneration.MethodParam;

/**
 * Is a parameter with a fixed value.
 *
 * @param  The type of the parameter value.
 * @since 0.57
 */
public abstract class FixedParam extends MethodParam {

  protected final T value;
  protected final T defaultValue;

  protected FixedParam(Class paramType, String expression, Function parser,
      T defaultValue) {
    super(paramType, expression);
    this.value = this.expression != null ? parser.apply(expression) : null;
    this.defaultValue = defaultValue;
  }

  protected FixedParam(Class paramType, T value, T defaultValue) {
    super(paramType, value == null ? null : value.toString());
    this.value = value;
    this.defaultValue = defaultValue;
  }

  @Override
  public boolean isDefault() {
    return super.isDefault() || defaultValue != null && defaultValue.equals(value);
  }

  /**
   * Gets the value associated to the parameter.
   *
   * @return the value.
   */
  public T getValue() {
    return value;
  }

  @Override
  public String buildCode(String indent) {
    return String.valueOf(value);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy