us.abstracta.jmeter.javadsl.codegeneration.params.FixedParam Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-java-dsl Show documentation
Show all versions of jmeter-java-dsl Show documentation
Simple API to run JMeter performance tests in an VCS and programmers friendly way.
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