*/
package org.mxchange.pizzaapplication.beans.category;
+import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.PostConstruct;
@Override
public void afterShopCategoryAdded (@Observes final AddedCategoryEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedCategory() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedCategory is null"); //NOI18N
+ } else if (event.getAddedCategory().getCategoryId() == null) {
+ // And again ...
+ throw new NullPointerException("event.addedCategory.categoryId is null"); //NOI18N
+ } else if (event.getAddedCategory().getCategoryId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedCategory.categoryId={0} is not valid.", event.getAddedCategory().getCategoryId())); //NOI18N
+ }
+
// Add it here, too.
this.addCategory(event.getAddedCategory());
}
*/
package org.mxchange.pizzaapplication.beans.product;
+import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
@Override
public void afterShopProductAdded (@Observes final AddedProductEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedProduct()== null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedProduct is null"); //NOI18N
+ } else if (event.getAddedProduct().getProductId() == null) {
+ // And again ...
+ throw new NullPointerException("event.addedProduct.productId is null"); //NOI18N
+ } else if (event.getAddedProduct().getProductId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedProduct.productId={0} is not valid.", event.getAddedProduct().getProductId())); //NOI18N
+ }
+
// Add it here, too.
this.addProduct(event.getAddedProduct());
}