Skip to content

Commit

Permalink
HUEditorRow.martchesStringFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jul 22, 2017
1 parent 3c0645e commit 8e280db
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/de/metas/ui/web/handlingunits/HUEditorRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;

Expand All @@ -15,6 +16,7 @@
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.InterfaceWrapperHelper;
import org.adempiere.util.Check;
import org.adempiere.util.StringUtils;
import org.compiere.model.I_C_UOM;
import org.compiere.util.Env;

Expand Down Expand Up @@ -499,6 +501,27 @@ public LookupValue toLookupValue()
{
return IntegerLookupValue.of(getM_HU_ID(), getSummary());
}

/**
* @param stringFilter
* @param adLanguage AD_Language (used to get the right row's string representation)
* @return true if the row is matching the string filter
*/
public boolean matchesStringFilter(final String stringFilter)
{
if (Check.isEmpty(stringFilter, true))
{
return true;
}

final String rowDisplayName = getSummary();

final Function<String, String> normalizer = s -> StringUtils.stripDiacritics(s.trim()).toLowerCase();
final String rowDisplayNameNorm = normalizer.apply(rowDisplayName);
final String stringFilterNorm = normalizer.apply(stringFilter);

return rowDisplayNameNorm.contains(stringFilterNorm);
}

//
//
Expand Down

0 comments on commit 8e280db

Please sign in to comment.