X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Forg%2Fmxchange%2Fjcoreee%2Fbean%2Ffaces%2FBaseFacesBean.java;h=ef7ed50f6f96da91c17203653cabce72579f4f3f;hb=7a50450e9a64fd0199b102409a727d1bbb340a13;hp=e71eb0716c3bb6b74c19a2b54cb6fd635ded2d0a;hpb=1f141c043a053621b86a5701420ca71f17a64e7b;p=jcoreee.git diff --git a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java index e71eb07..ef7ed50 100644 --- a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java +++ b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java @@ -16,6 +16,8 @@ */ package org.mxchange.jcoreee.bean.faces; +import java.io.Serializable; +import java.math.BigDecimal; import java.security.Principal; import java.text.MessageFormat; import java.util.ArrayList; @@ -25,14 +27,13 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; -import org.mxchange.jcoreee.bean.BaseBean; /** * An abstract bean for faces (web) projects. *
* @author Roland Häder
+ * @param value Actual value to check
+ * @param filter Filter value to check against {@code value}
+ * @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")
+ public boolean filterByPrice (final Object value, final Object filter, final Locale locale) {
+ // Get trimmed string or NULL
+ final String filterText = (filter == null) ? null : filter.toString().trim();
+
+ // Is null or empty?
+ if (filterText == null || filterText.isEmpty()) {
+ // Then return TRUE
+ return true;
+ }
+
+ // Is value NULL or not castable?
+ if (value == null) {
+ // Return FALSE
+ return false;
+ } else if (!(value instanceof Comparable)) {
+ // Not castable
+ throw new ClassCastException("value is not instance of Comparable");
+ }
+
+ // Do the cast and compare
+ return ((Comparable