package fr.esiea.windmeal.model;

import org.joda.time.DateTime;

import java.util.Set;

/**
 * Copyright (c) 2013 ESIEA M. Labusquiere D. Déïs
 * <p/>
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * <p/>
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * <p/>
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
public class Order extends Model {

	private String foodProviderId;
	private Set<MealOrder> meals;
	private DateTime orderDate;
	private boolean state;

	public String getFoodProviderId() {
		return foodProviderId;
	}

	public void setFoodProviderId(String foodProviderId) {
		this.foodProviderId = foodProviderId;
	}

	public Set<MealOrder> getMeals() {
		return meals;
	}

	public void setMeals(Set<MealOrder> meals) {
		this.meals = meals;
	}

	public DateTime getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(DateTime orderDate) {
		this.orderDate = orderDate;
	}

	public boolean isState() {
		return state;
	}

	public void setState(boolean state) {
		this.state = state;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		if (!super.equals(o)) return false;

		Order order = (Order) o;

		if (state != order.state) return false;
		if (!foodProviderId.equals(order.foodProviderId)) return false;
		if (!meals.equals(order.meals)) return false;
		if (!orderDate.equals(order.orderDate)) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = super.hashCode();
		result = 31 * result + foodProviderId.hashCode();
		result = 31 * result + meals.hashCode();
		result = 31 * result + orderDate.hashCode();
		result = 31 * result + (state ? 1 : 0);
		return result;
	}
}

@@ -1930,25 +1930,28 @@
  state;%0A%09%7D%0A%0A
-%09
+    
 @Override%0A%09p
@@ -1944,25 +1944,28 @@
   @Override%0A
-%09
+    
 public boole
@@ -1986,18 +1986,24 @@
 ct o) %7B%0A
-%09%09
+        
 if (this
@@ -2026,52 +2026,40 @@
 ue;%0A
-%09%09if (o == null %7C%7C getClass() != o.getClass(
+        if (!(o instanceof Order
 )) r
@@ -2067,26 +2067,32 @@
 turn false;%0A
-%09%09
+        
 if (!super.e
@@ -2116,18 +2116,24 @@
 false;%0A%0A
-%09%09
+        
 Order or
@@ -2150,18 +2150,24 @@
 er) o;%0A%0A
-%09%09
+        
 if (stat
@@ -2198,22 +2198,53 @@
  false;%0A
-%09%09if (
+        if (foodProviderId != null ? 
 !foodPro
@@ -2283,78 +2283,191 @@
 rId)
-) return false;%0A%09%09if (!meals.equals(order.meals)) return false;%0A%09%09if (
+ : order.foodProviderId != null)%0A            return false;%0A        if (meals != null ? !meals.equals(order.meals) : order.meals != null) return false;%0A        if (orderDate != null ? 
 !ord
@@ -2496,16 +2496,42 @@
 derDate)
+ : order.orderDate != null
 ) return
@@ -2539,18 +2539,24 @@
 false;%0A%0A
-%09%09
+        
 return t
@@ -2560,21 +2560,27 @@
 n true;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -2581,17 +2581,20 @@
 verride%0A
-%09
+    
 public i
@@ -2609,18 +2609,24 @@
 ode() %7B%0A
-%09%09
+        
 int resu
@@ -2640,34 +2640,40 @@
 per.hashCode();%0A
-%09%09
+        
 result = 31 * re
@@ -2678,16 +2678,42 @@
 result +
+ (foodProviderId != null ?
  foodPro
@@ -2722,36 +2722,47 @@
 derId.hashCode()
-;%0A%09%09
+ : 0);%0A        
 result = 31 * re
@@ -2767,16 +2767,33 @@
 result +
+ (meals != null ?
  meals.h
@@ -2793,36 +2793,47 @@
 meals.hashCode()
-;%0A%09%09
+ : 0);%0A        
 result = 31 * re
@@ -2838,16 +2838,37 @@
 result +
+ (orderDate != null ?
  orderDa
@@ -2880,20 +2880,31 @@
 shCode()
-;%0A%09%09
+ : 0);%0A        
 result =
@@ -2935,18 +2935,24 @@
 1 : 0);%0A
-%09%09
+        
 return r
@@ -2958,13 +2958,16 @@
 result;%0A
-%09
+    
 %7D%0A%7D%0A

fix hashcode and equal