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

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

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

import com.fasterxml.jackson.databind.util.StdConverter;
import com.google.common.base.Strings;
import com.neotys.neoload.model.v3.project.scenario.StopAfter;

public final class StringToStopAfterConverter extends StdConverter {
	private static final StopAfter ERROR_VALUE = StopAfter.builder().build();

	@Override
	public StopAfter convert(final String input) {
		if (Strings.isNullOrEmpty(input)) {
			return ERROR_VALUE;
		}
		
		// Time case
		final Integer value = TimeDurationHelper.convertToInteger(input);
		if (value != null) {
			return StopAfter.builder()
					.value(value)
					.type(StopAfter.Type.TIME)
					.build();		
		}
		// Current Iteration case
		if ("current_iteration".equals(input.trim())) {
			return StopAfter.builder()
					.type(StopAfter.Type.CURRENT_ITERATION)
					.build();
		}
		return ERROR_VALUE;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy