From 6a645233a0fc75198c6462a4fe3f5ed37c4da5e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Jan 2023 04:04:26 +0100 Subject: [PATCH] Continued: - fixed some misuse of valueOf()/parse() methods which fixes some flaws the inspector from Netbeans IDE has found - no need to compare Boolean.parseBoolean() with Boolean.TRUE, just return it directly without comparison --- .../jcoreee/bean/faces/BaseFacesBean.java | 8 ++--- .../mxchange/jcoreee/dates/DayOfTheWeek.java | 35 +++++++++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java index be104a1..48dd2eb 100644 --- a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java +++ b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java @@ -87,7 +87,7 @@ public abstract class BaseFacesBean implements Serializable { * @param locale Locale *

* @return Whether price ({@code value}) is at least {@code filter} - * + *

* @see https://www.primefaces.org/showcase/ui/data/datatable/filter.xhtml */ @SuppressWarnings ("unchecked") @@ -111,7 +111,7 @@ public abstract class BaseFacesBean implements Serializable { } // Do the cast and compare - return ((Comparable) value).compareTo(BigDecimal.valueOf(Double.valueOf(filterText))) >= 0; + return ((Comparable) value).compareTo(BigDecimal.valueOf(Double.parseDouble(filterText))) >= 0; } /** @@ -155,7 +155,7 @@ public abstract class BaseFacesBean implements Serializable { } // Get context parameter - final Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); + final Integer contextValue = Integer.valueOf(this.getStringContextParameter(parameterKey)); // Return it return contextValue; @@ -263,7 +263,7 @@ public abstract class BaseFacesBean implements Serializable { final String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N // Return it - return (Boolean.parseBoolean(contextParameter) == Boolean.TRUE); + return Boolean.parseBoolean(contextParameter); } /** diff --git a/src/org/mxchange/jcoreee/dates/DayOfTheWeek.java b/src/org/mxchange/jcoreee/dates/DayOfTheWeek.java index d546c7b..a3e764c 100644 --- a/src/org/mxchange/jcoreee/dates/DayOfTheWeek.java +++ b/src/org/mxchange/jcoreee/dates/DayOfTheWeek.java @@ -28,6 +28,9 @@ import java.util.GregorianCalendar; * @author Roland Häder */ public enum DayOfTheWeek { + /** + * Enumeration for Sunday + */ SUNDAY { @Override public int toCalendar () { @@ -35,36 +38,54 @@ public enum DayOfTheWeek { } }, + /** + * Enumeration for Monday + */ MONDAY { @Override public int toCalendar () { return Calendar.MONDAY; } }, + /** + * Enumeration for Tuesay + */ TUESDAY { @Override public int toCalendar () { return Calendar.TUESDAY; } }, + /** + * Enumeration for Wednesday + */ WEDNESDAY { @Override public int toCalendar () { return Calendar.WEDNESDAY; } }, + /** + * Enumeration for Thursday + */ THURSDAY { @Override public int toCalendar () { return Calendar.THURSDAY; } }, + /** + * Enumeration for Friday + */ FRIDAY { @Override public int toCalendar () { return Calendar.FRIDAY; } }, + /** + * Enumeration for Saturday + */ SATURDAY { @Override public int toCalendar () { @@ -85,6 +106,11 @@ public enum DayOfTheWeek { SIMPLE_DATE_FORMAT.applyPattern("EEEEEEEEEE"); //NOI18N } + /** + * Returns index from enumeration + *

+ * @return Index of enumeration + */ public abstract int toCalendar (); /** @@ -99,11 +125,11 @@ public enum DayOfTheWeek { DayOfTheWeek dayOfTheWeek = null; // Walk through all values - for (final DayOfTheWeek dayOfWeek : DayOfTheWeek.values()) { + for (final DayOfTheWeek currentDayOfTheWeek : DayOfTheWeek.values()) { // Has the day being found? - if (dayOfWeek.toCalendar() == day) { + if (currentDayOfTheWeek.toCalendar() == day) { // Found it and break out from lopp - dayOfTheWeek = dayOfWeek; + dayOfTheWeek = currentDayOfTheWeek; break; } } @@ -136,9 +162,6 @@ public enum DayOfTheWeek { return fromCalendarDay(calendar.get(Calendar.DAY_OF_WEEK)); } - /* - * Should return the localized day of the week - */ @Override public String toString () { // Init calendar -- 2.39.5