Tabnine Logo
SelectionModel.filter
Code IndexAdd Tabnine to your IDE (free)

How to use
filter
method
in
cc.lasmgratel.foodcraftreloaded.api.util.selection.SelectionModel

Best Java code snippets using cc.lasmgratel.foodcraftreloaded.api.util.selection.SelectionModel.filter (Showing top 2 results out of 315)

origin: NanamiArihara/FoodCraft-Reloaded

/**
 * Using custom pattern.
 * Modes are switched by the first letter.
 * R for Regex
 * S for StartsWith
 * E for EndsWith
 * Q or any other letter for Equals
 * C for Contains
 */
public SelectionModel<T> filter(String pattern) {
  return filter(s -> {
    if (s.isEmpty())
      return false;
    char firstChar = pattern.charAt(0);
    switch (firstChar) {
      case 'R':
        return SelectPredicates.REGEX.test(s, pattern.substring(1));
      case 'S':
        return SelectPredicates.STARTS.test(s, pattern.substring(1));
      case 'E':
        return SelectPredicates.ENDS.test(s, pattern.substring(1));
      case 'Q':
        return SelectPredicates.EQUAL.test(s, pattern.substring(1));
      case 'C':
        return SelectPredicates.CONTAINS.test(s, pattern.substring(1));
      default:
        return SelectPredicates.EQUAL.test(s, pattern);
    }
  });
}
origin: NanamiArihara/FoodCraft-Reloaded

@Test
public void testFilter() {
  assertTrue(
    Selector.wrap("ironIngot", "ironPlate", "ironStick", "bronzeIngot", "bronzeStick")
      .filter("Siron")
      .stream()
      .allMatch(s -> s.getName().startsWith("iron"))
  );
}
cc.lasmgratel.foodcraftreloaded.api.util.selectionSelectionModelfilter

Javadoc

Using custom pattern. Modes are switched by the first letter. R for Regex S for StartsWith E for EndsWith Q or any other letter for Equals C for Contains

Popular methods of SelectionModel

  • <init>
  • stream

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Notification (javax.management)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now