org.mockserver.model.Delay Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.model;
import java.util.concurrent.TimeUnit;
/**
* @author jamesdbloom
*/
public class Delay extends EqualsHashCodeToString {
private final TimeUnit timeUnit;
private final long value;
public Delay(TimeUnit timeUnit, long value) {
this.timeUnit = timeUnit;
this.value = value;
}
public TimeUnit getTimeUnit() {
return timeUnit;
}
public long getValue() {
return value;
}
public void applyDelay() {
if (timeUnit != null) {
try {
timeUnit.sleep(value);
} catch (InterruptedException ie) {
logger.error("InterruptedException while apply delay to response", ie);
throw new RuntimeException("InterruptedException while apply delay to response", ie);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy