package common;

/**
 * A Class to represent a direction
 */
public enum Direction {
	UP,
	DOWN;

	/**
	 * Try to get the matching direction from the input string
	 *
	 * @param inputStr
	 *            the string that is used to find a direction
	 * @return the matching direction, or null if none matching
	 */
	public static Direction getDirection(String inputStr) {
		for (Direction direction : Direction.values()) {
			if (inputStr.equalsIgnoreCase(direction.name())) {
				return direction;
			}
		}
		return null;
	}

	/**
	 * Gets a direction given a motor
	 * @param motor
	 * @return
	 */
	public static Direction mapDirection(Motor motor) {
		if (motor == Motor.UP) {
			return UP;
		} else if (motor == Motor.DOWN) {
			return DOWN;
		}
		return null;
	}
}
