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

com.neotys.neoload.model.v3.binding.converter.TimeDurationInMsOrInVariableToStringConverter Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.binding.converter;

import com.fasterxml.jackson.databind.util.StdConverter;

import static com.google.common.base.Strings.isNullOrEmpty;

public final class TimeDurationInMsOrInVariableToStringConverter extends StdConverter {
	private static final String ERROR_VALUE = "0";

	public static final TimeDurationInMsOrInVariableToStringConverter TIME_DURATION_IN_MS_OR_IN_VARIABLE_TO_STRING = new TimeDurationInMsOrInVariableToStringConverter();

	private TimeDurationInMsOrInVariableToStringConverter() {
		//do nothing
	}

	@Override
	public String convert(final String input) {
		if (isNullOrEmpty(input)) {
			return ERROR_VALUE;
		}

		if (input.startsWith("${") && input.endsWith("}")) {
			//variable
			return input;
		}

		return TimeDurationInMsHelper.convertToString(Long.valueOf(input));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy