2 * Copyright (C) 2016 - 2018 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jproduct.events.product.updated;
19 import java.text.MessageFormat;
20 import org.mxchange.jproduct.model.product.Product;
23 * An event fired when a new shop category has been updated.
25 * @author Roland Häder<roland@mxchange.org>
27 public class ProductUpdatedEvent implements UpdatedProductEvent {
32 private static final long serialVersionUID = 18_567_817_669_108L;
35 * Product instance that has been updated
37 private final Product updatedProduct;
40 * Constructor with updated product instance
42 * @param updatedProduct Updated product
44 public ProductUpdatedEvent (final Product updatedProduct) {
45 // The category should be valid
46 if (null == updatedProduct) {
48 throw new NullPointerException("updatedProduct is null"); //NOI18N
49 } else if (updatedProduct.getProductI18nKey().isEmpty()) {
51 throw new IllegalArgumentException("updatedProduct.productI18nKey is empty"); //NOI18N
52 } else if (updatedProduct.getProductId() == null) {
54 throw new NullPointerException("updatedProduct.productId is null"); //NOI18N
55 } else if (updatedProduct.getProductId() <= 0) {
57 throw new IllegalArgumentException(MessageFormat.format("updatedProduct.productId={0} is not valid.", updatedProduct.getProductId())); //NOI18N
58 } else if (updatedProduct.getProductCategory() == null) {
60 throw new NullPointerException("updatedProduct.productCategory is null"); //NOI18N
61 } else if (updatedProduct.getProductCategory().getCategoryId() == null) {
63 throw new NullPointerException("updatedProduct.productCategory.categoryId is null"); //NOI18N
64 } else if (updatedProduct.getProductCategory().getCategoryId() <= 0) {
66 throw new IllegalArgumentException(MessageFormat.format("updatedProduct.productCategory.categoryId={0} is not valid.", updatedProduct.getProductId())); //NOI18N
70 this.updatedProduct = updatedProduct;
74 public Product getUpdatedProduct () {
75 return this.updatedProduct;