From: Roland Haeder Date: Thu, 27 Aug 2015 06:52:34 +0000 (+0200) Subject: Better compare this way: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=52660c6eea816d84c94a287dad096bb4720799ab;p=pizzaservice-war.git Better compare this way: if (null == foo) Otherwise could lead to a bug if you miss only one equal sign + updated jcore Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index f4bdc108..d75f9b63 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java index 27a3f099..8fe69815 100644 --- a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java +++ b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java @@ -46,7 +46,7 @@ public class BasePizzaServiceSystem extends BaseFrameworkSystem { this.getLogger().debug(MessageFormat.format("value={0}", value)); //NOI18N // Is it null? - if (value == null) { + if (null == value) { // Value is null throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name)); //NOI18N } else if (name.equals("database.backend.storagepath")) { //NOI18N diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index 51e3d377..2507b024 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -78,7 +78,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ public static final PizzaApplication getInstance (final ServletContext context) throws ServletException { // Check application instance - if (context == null) { + if (null == context) { // Not set throw new NullPointerException("application is null"); //NOI18N } @@ -164,7 +164,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N // Is product and session set? - if (request == null) { + if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -216,7 +216,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N // Is product and session set? - if (request == null) { + if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -291,7 +291,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P Object object = this.getValueFromSession(product, session, HTTP_PARAM_AMOUNT); // Is the object null? - if (object == null) { + if (null == object) { // Trace message this.getLogger().trace("Returning 0 - EXIT!"); //NOI18N @@ -323,7 +323,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -372,7 +372,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P Object object = this.getValueFromSession(product, session, HTTP_PARAM_ITEM_ID); // Is the object null? - if (object == null) { + if (null == object) { // Not found this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getItemId())); //NOI18N return ""; //NOI18N @@ -398,7 +398,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N // Is product and session set? - if (request == null) { + if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -445,7 +445,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -528,7 +528,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == session) { // Abort here throw new NullPointerException("session is null"); //NOI18N - } else if (key == null) { + } else if (null == key) { // Abort here throw new NullPointerException("key is null"); //NOI18N } @@ -609,7 +609,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -685,7 +685,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -752,7 +752,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -1038,7 +1038,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (request == null) { + } else if (null == request) { // Not set throw new NullPointerException("request is null"); //NOI18N } else if (null == session) { @@ -1069,7 +1069,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getItemId(), object)); //NOI18N // Is it null? - if (object == null) { + if (null == object) { // Unset session this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getItemId())); //NOI18N this.clearSessionAttribute(product, session, HTTP_PARAM_ITEM_ID); @@ -1237,7 +1237,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // request must not be null - if (request == null) { + if (null == request) { // Is null throw new NullPointerException("request is null"); //NOI18N } @@ -1253,7 +1253,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P Integer id = 0; // Check all fields - if (title == null) { + if (null == title) { // "title" not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { @@ -1302,7 +1302,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // request must not be null - if (request == null) { + if (null == request) { // Is null throw new NullPointerException("request is null"); //NOI18N } @@ -1321,25 +1321,25 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P Float p = null; // Check all fields - if (title == null) { + if (null == title) { // "title" not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { // Is left empty throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N - } else if (price == null) { + } else if (null == price) { // "price" not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_PRICE)); //NOI18N } else if (price.isEmpty()) { // Is left empty throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_PRICE)); //NOI18N - } else if (category == null) { + } else if (null == category) { // "title" not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_CATEGORY)); //NOI18N } else if (category.isEmpty()) { // Is left empty throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_CATEGORY)); //NOI18N - } else if (available == null) { + } else if (null == available) { // "title" not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_AVAILABLE)); //NOI18N } else if (available.isEmpty()) { @@ -1398,7 +1398,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N // category must not be null - if (category == null) { + if (null == category) { // Is null throw new NullPointerException("category is null"); //NOI18N } @@ -1477,10 +1477,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P String title = request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE); // request must not be null and "title" must be found and non-empty - if (request == null) { + if (null == request) { // Abort here throw new NullPointerException("request is null"); //NOI18N - } else if (title == null) { + } else if (null == title) { // title is not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { @@ -1510,10 +1510,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0},response={1} - CALLED!", request, response)); //NOI18N // request and response must both be set - if (request == null) { + if (null == request) { // request is null throw new NullPointerException("request is null"); //NOI18N - } else if (response == null) { + } else if (null == response) { // response is null throw new NullPointerException("response is null"); //NOI18N } @@ -1566,10 +1566,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0},response={1} - CALLED!", request, response)); //NOI18N // request and response must both be set - if (request == null) { + if (null == request) { // request is null throw new NullPointerException("request is null"); //NOI18N - } else if (response == null) { + } else if (null == response) { // response is null throw new NullPointerException("response is null"); //NOI18N } @@ -1631,10 +1631,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P String title = request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE); // request must not be null and "title" must be found and non-empty - if (request == null) { + if (null == request) { // Abort here throw new NullPointerException("request is null"); //NOI18N - } else if (title == null) { + } else if (null == title) { // title is not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { diff --git a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java index 35b68a9f..208cfb68 100644 --- a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java +++ b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java @@ -74,7 +74,7 @@ public class BaseCategory extends BaseFrameworkSystem implements Category { this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N // category should not be null - if (category == null) { + if (null == category) { throw new NullPointerException("category is null"); //NOI18N } diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java index b6097c9b..1d03b562 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java @@ -223,7 +223,7 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); //NOI18N // Is map null? - if (map == null) { + if (null == map) { // Is null throw new NullPointerException("map is null"); //NOI18N } else if (map.isEmpty()) { @@ -366,6 +366,9 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId); criteria.setLimit(1); + // Add logical matcher + criteria.setLogical(new AndLogicalMatcher()); + // Now search for it Result result = this.getBackend().doSelectByCriteria(criteria); diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java index 32602a8d..aea48416 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java @@ -74,7 +74,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen this.getLogger().trace(MessageFormat.format("title={0},parent={1} - CALLED!", title, parent)); //NOI18N // Title should not be null - if (title == null) { + if (null == title) { // Abort here throw new NullPointerException("title is null"); //NOI18N } @@ -154,10 +154,10 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen this.getLogger().trace("CALLED!"); //NOI18N // Instance search criteria - SearchableCriteria critera = new SearchCriteria(); + SearchableCriteria criteria = new SearchCriteria(); // Run the query - Result result = this.getBackend().doSelectByCriteria(critera); + Result result = this.getBackend().doSelectByCriteria(criteria); // Debug message this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N @@ -340,7 +340,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); //NOI18N // Is map null? - if (map == null) { + if (null == map) { // Is null throw new NullPointerException("map is null"); //NOI18N } else if (map.isEmpty()) { diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java index 55729e7f..6059cf46 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -73,16 +73,16 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); //NOI18N // Title should not be null - if (title == null) { + if (null == title) { // Abort here throw new NullPointerException("title is null"); //NOI18N - } else if (price == null) { + } else if (null == price) { // Abort here throw new NullPointerException("price is null"); //NOI18N - } else if (category == null) { + } else if (null == category) { // Abort here throw new NullPointerException("category is null"); //NOI18N - } else if (available == null) { + } else if (null == available) { // Abort here throw new NullPointerException("available is null"); //NOI18N } @@ -169,10 +169,10 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement this.getLogger().trace("CALLED!"); //NOI18N // Instance search criteria - SearchableCriteria critera = new SearchCriteria(); + SearchableCriteria criteria = new SearchCriteria(); // Run the query - Result result = this.getBackend().doSelectByCriteria(critera); + Result result = this.getBackend().doSelectByCriteria(criteria); // Debug message this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N @@ -194,13 +194,13 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement this.getLogger().trace("CALLED!"); //NOI18N // Instance search criteria - SearchableCriteria critera = new SearchCriteria(); + SearchableCriteria criteria = new SearchCriteria(); // Add criteria - critera.addCriteria(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, true); + criteria.addCriteria(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, true); // Run the query - Result result = this.getBackend().doSelectByCriteria(critera); + Result result = this.getBackend().doSelectByCriteria(criteria); // Debug message this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N @@ -326,7 +326,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); //NOI18N // Is map null? - if (map == null) { + if (null == map) { // Is null throw new NullPointerException("map is null"); //NOI18N } else if (map.isEmpty()) { diff --git a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java index 13b96c95..3cfa682a 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java @@ -48,13 +48,13 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { this.getLogger().trace(MessageFormat.format("request={0},response={1},chain={2} - CALLED!", request, response, chain)); //NOI18N // All must be set - if (request == null) { + if (null == request) { // request is null throw new NullPointerException("request is null"); //NOI18N - } else if (response == null) { + } else if (null == response) { // response is null throw new NullPointerException("response is null"); //NOI18N - } else if (chain == null) { + } else if (null == chain) { // chain is null throw new NullPointerException("chain is null"); //NOI18N } @@ -69,7 +69,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { this.getLogger().debug(MessageFormat.format("object={0}", object)); //NOI18N // item should not be null - if (object == null) { + if (null == object) { // item is null throw new NullPointerException("item is null"); //NOI18N } else if (!(object instanceof AddableBasketItem)) { diff --git a/web/form_handler/add_item.jsp b/web/form_handler/add_item.jsp index e3451d06..b3d8ca83 100644 --- a/web/form_handler/add_item.jsp +++ b/web/form_handler/add_item.jsp @@ -24,7 +24,7 @@ app.getLogger().debug("amount=" + amount); // Is amount null or zero? - if ((amount == null) || (amount == 0)) { + if ((null == amount) || (amount == 0)) { // Then redirect to added=0 response.sendRedirect(request.getContextPath() + "/?add=0"); } else {