/******************************************************************************* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 2013,2014 by Peter Pilgrim, Addiscombe, Surrey, XeNoNiQUe UK * * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU GPL v3.0 * which accompanies this distribution, and is available at: * http://www.gnu.org/licenses/gpl-3.0.txt * * Developers: * Peter Pilgrim -- design, development and implementation * -- Blog: http://www.xenonique.co.uk/blog/ * -- Twitter: @peter_pilgrim * * Contributors: * *******************************************************************************/ package je7hb.basic.ejb; import java.io.Serializable; /** * The immutable type OrderItem * * @author Peter Pilgrim */ public final class OrderItem implements Serializable { private final int quantity; private final Product product; public OrderItem(int quantity, Product product) { this.quantity = quantity; this.product = product; } public int getQuantity() { return quantity; } public Product getProduct() { return product; } @Override public String toString() { return "OrderItem{" + "quantity=" + quantity + ", product=" + product + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof OrderItem)) return false; OrderItem orderItem = (OrderItem) o; if (quantity != orderItem.quantity) return false; if (product != null ? !product.equals(orderItem.product) : orderItem.product != null) return false; return true; } @Override public int hashCode() { int result = quantity; result = 31 * result + (product != null ? product.hashCode() : 0); return result; } }