package common;

/**
 * This enum represents the possible errors that can be injected into the system
 */
public enum ErrorType {
	STUCK_OPEN(1), STUCK_CLOSE(2), STUCK_MOTOR(3);

	private int value;

	private ErrorType(int value) {
		this.value = value;
	}

	/**
	 * Get the error associated with the integer value
	 *
	 * @param value integer value in config file
	 * @return the error type associated with the int, null if none
	 */
	public static ErrorType getErrorForValue(int value) {
		for (ErrorType errorType : ErrorType.values()) {
			if (errorType.getValue() == value) {
				return errorType;
			}
		}

		return null;
	}

	private int getValue() {
		return value;
	}
}
