package com.github.sbugat.ec2tools.model.instance;

/**
 * Loaded instance order.
 * 
 * @author Sylvain Bugat
 */
public final class InstanceOrder {

	/** Instande identifier of the order. */
	private final String instanceId;

	/** Type of the order. */
	private final OrderType orderType;

	/**
	 * Copy arguments constructor.
	 * 
	 * @param instanceIdArg instance identifier to copy
	 * @param orderTypeArg order type to copy
	 */
	public InstanceOrder(final String instanceIdArg, final String orderTypeArg) {

		instanceId = instanceIdArg;
		orderType = OrderType.valueOf(orderTypeArg);
	}

	/**
	 * Return the instance identifier.
	 * 
	 * @return instance identifier
	 */
	public String getInstanceId() {
		return instanceId;
	}

	/**
	 * return the order type.
	 * 
	 * @return order type
	 */
	public OrderType getOrderType() {
		return orderType;
	}

	@Override
	public String toString() {
		return instanceId + ':' + orderType;
	}

	@Override
	public int hashCode() {
		final int prime = 31;

		int result = prime;
		if (null != instanceId) {
			result += instanceId.hashCode();
		}

		result *= prime;
		if (null != orderType) {
			result += orderType.hashCode();
		}

		return result;
	}

	@Override
	public boolean equals(final Object object) {

		if (this == object) {
			return true;
		}

		if (object == null || !InstanceOrder.class.isInstance(object)) {
			return false;
		}

		final InstanceOrder instanceOrder = (InstanceOrder) object;

		if (instanceId != null && !instanceId.equals(instanceOrder.instanceId) || orderType != instanceOrder.orderType) {
			return false;
		}

		return true;
	}
}

@@ -81,17 +81,16 @@
 der.%0D%0A *
- 
 %0D%0A * @au
@@ -337,25 +337,24 @@
 ructor.%0D%0A%09 *
- 
 %0D%0A%09 * @param
@@ -656,25 +656,24 @@
 tifier.%0D%0A%09 *
- 
 %0D%0A%09 * @retur
@@ -800,17 +800,16 @@
 pe.%0D%0A%09 *
- 
 %0D%0A%09 * @r
@@ -1536,31 +1536,16 @@
 if (
-instanceId != 
 null 
-&& !
+== 
 inst
@@ -1554,16 +1554,28 @@
 ceId
-.equals(
+) %7B%0D%0A%09%09%09if (null != 
 inst
@@ -1596,18 +1596,55 @@
 anceId) 
-%7C%7C
+%7B%0D%0A%09%09%09%09return false;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09return
  orderTy
@@ -1646,17 +1646,17 @@
 derType 
-!
+=
 = instan
@@ -1664,33 +1664,43 @@
 eOrder.orderType
-)
+;%0D%0A%09%09%7D else
  %7B%0D%0A%09%09%09return fa
@@ -1701,37 +1701,97 @@
 urn 
-false;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09return true;
+instanceId.equals(instanceOrder.instanceId) && orderType == instanceOrder.orderType;%0D%0A%09%09%7D
 %0D%0A%09%7D

Fix equals