Package com.softserve.academy.food.model

Source Code of com.softserve.academy.food.model.mHistoryOrders

package com.softserve.academy.food.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.softserve.academy.food.entity.eHistoryOrders;
import com.softserve.academy.food.entity.eOrder;
import com.softserve.academy.food.model.mOrder;

public class mHistoryOrders
{
  private int id;
  private mUserCredentials user;
  private String description;
  private Date data;
  private List<mOrder> orders = new ArrayList<mOrder>();
 
 
  public mHistoryOrders()
  {
  }
  
  public mHistoryOrders( eHistoryOrders history )
  {
    List<mOrder> orders = new ArrayList<mOrder>();
    id = history.getId();
   
    for (eOrder order : history.getOrders())
    {
      orders.add( new mOrder(order) );
    }
    this.orders = orders;
   
    user = new mUserCredentials( history.getUser() );
    description = history.getDescription();
    data = history.getData();
  }

  public int getId()
  {
    return id;
  }

  public void setId(int id)
  {
    this.id = id;
  }

  public mUserCredentials getUser()
  {
    return user;
  }

  public void setUser(mUserCredentials user)
  {
    this.user = user;
  }

  public String getDescription()
  {
    return description;
  }

  public void setDescription( String description )
  {
    this.description = description;
  }

  public Date getData()
  {
    return data;
  }

  public void setData( Date data )
  {
    this.data = data;
  }

  public List<mOrder> getOrders()
  {
    return orders;
  }

  public void setOrders( List<mOrder> orders )
  {
    this.orders = orders;
  }

  @Override
  public int hashCode()
  {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((data == null) ? 0 : data.hashCode());
    result = prime * result
        + ((description == null) ? 0 : description.hashCode());
    result = prime * result + id;
    result = prime * result + ((orders == null) ? 0 : orders.hashCode());
    result = prime * result + ((user == null) ? 0 : user.hashCode());
    return result;
  }

  @Override
  public boolean equals( Object obj )
  {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (!(obj instanceof mHistoryOrders))
      return false;
    mHistoryOrders other = (mHistoryOrders) obj;
    if (data == null)
    {
      if (other.data != null)
        return false;
    } else if (!data.equals(other.data))
      return false;
    if (description == null)
    {
      if (other.description != null)
        return false;
    } else if (!description.equals(other.description))
      return false;
    if (id != other.id)
      return false;
    if (orders == null)
    {
      if (other.orders != null)
        return false;
    } else if (!orders.equals(other.orders))
      return false;
    if (user == null)
    {
      if (other.user != null)
        return false;
    } else if (!user.equals(other.user))
      return false;
    return true;
  }

  @Override
  public String toString()
  {
    return "mHistoryOrders [id=" + id + ", user=" + user + ", description="
        + description + ", data=" + data + ", orders=" + orders + "]";
  }

}
TOP

Related Classes of com.softserve.academy.food.model.mHistoryOrders

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.