Codota Logo
Pattern.asPredicate
Code IndexAdd Codota to your IDE (free)

How to use
asPredicate
method
in
java.util.regex.Pattern

Best Java code snippets using java.util.regex.Pattern.asPredicate (Showing top 20 results out of 423)

  • Common ways to obtain Pattern
private void myMethod () {
Pattern p =
  • Codota IconString regex;Pattern.compile(regex)
  • Codota IconString regex;Pattern.compile(regex, flags)
  • Codota IconStringBuffer regex;Pattern.compile(regex.toString())
  • Smart code suggestions by Codota
}
origin: KronicDeth/intellij-elixir

public Pattern(@NotNull java.util.regex.Pattern pattern) {
  this(pattern.asPredicate());
}
origin: stackoverflow.com

 private static final Predicate<String> IS_NOT_SPACES_ONLY = 
    Pattern.compile("^\\s*$").asPredicate().negate();

public static String implode(String delimiter, String... data) {
  return Arrays.stream(data)
      .filter(IS_NOT_SPACES_ONLY)
      .collect(Collectors.joining(delimiter));
}
origin: apache/hive

 /**
  * Compile a list of regex patterns and collect them as Predicates.
  * @param patterns List of regex patterns to be compiled
  * @return a List of Predicate created by compiling the regex patterns
  */
 public static List<Predicate<String>> compilePatternsToPredicates(List<String> patterns) {
  return patterns.stream().map(pattern -> compile(pattern).asPredicate()).collect(Collectors.toList());
 }
}
origin: speedment/speedment

private boolean checkIf(Document doc, String param, String value) {
  final Pattern pattern = Pattern.compile(value);
  return doc.get(param)
    .map(Object::toString)
    .filter(pattern.asPredicate())
    .isPresent();
}
origin: spotify/helios

@Override
public List<String> listHosts(final String namePatternFilter) {
 Preconditions.checkNotNull(namePatternFilter, "namePatternFilter");
 final Predicate<String> matchesPattern = Pattern.compile(namePatternFilter).asPredicate();
 return listHosts().stream()
   .filter(matchesPattern)
   .collect(Collectors.toList());
}
origin: apache/storm

/**
 * Get the filtered, authorized, sorted log files for a port.
 */
@VisibleForTesting
List<File> logsForPort(String user, File portDir) {
  try {
    List<File> workerLogs = directoryCleaner.getFilesForDir(portDir).stream()
        .filter(file -> WORKER_LOG_FILENAME_PATTERN.asPredicate().test(file.getName()))
        .collect(toList());
    return workerLogs.stream()
        .filter(log -> resourceAuthorizer.isUserAllowedToAccessFile(user, WorkerLogs.getTopologyPortWorkerLog(log)))
        .sorted((f1, f2) -> (int) (f2.lastModified() - f1.lastModified()))
        .collect(toList());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
origin: apache/hive

private void testMapFilter(Map<String, String> testMap, List<String> patterns) {
 List<Predicate<String>> paramsFilter =
   patterns.stream().map(pattern -> compile(pattern).asPredicate()).collect(Collectors.toList());
 filterMapkeys(testMap, paramsFilter);
}
origin: joel-costigliola/assertj-core

/**
 * Asserts that a sequence of the message of the actual {@code Throwable} matches with the given regular expression (see {@link java.util.regex.Matcher#find()}).
 * The Pattern used under the hood enables the {@link Pattern#DOTALL} mode.
 *
 * @param info contains information about the assertion.
 * @param actual the given {@code Throwable}.
 * @param regex the regular expression expected to be found in the actual {@code Throwable}'s message.
 * @throws AssertionError if the actual {@code Throwable} is {@code null}.
 * @throws AssertionError if the message of the actual {@code Throwable} doesn't contain any sequence matching with the given regular expression
 * @throws NullPointerException if the regex is null
 */
public void assertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex) {
 checkNotNull(regex, "regex must not be null");
 assertNotNull(info, actual);
 Objects.instance().assertNotNull(info, actual.getMessage(), "exception message of actual");
 if (Pattern.compile(regex, Pattern.DOTALL).asPredicate().test(actual.getMessage())) return;
 throw failures.failure(info, shouldHaveMessageFindingMatchRegex(actual, regex));
}
origin: apache/metron

private static boolean isMatch(String regex, String field) {
 try {
  Pattern p = PatternCache.INSTANCE.getPattern(regex);
  if (p == null) {
   return false;
  }
  return p.asPredicate().test(field);
 }
 catch(PatternSyntaxException pse) {
  return false;
 }
}
origin: org.springframework.boot/spring-boot-actuator

@ReadOperation
public EnvironmentDescriptor environment(@Nullable String pattern) {
  if (StringUtils.hasText(pattern)) {
    return getEnvironmentDescriptor(Pattern.compile(pattern).asPredicate());
  }
  return getEnvironmentDescriptor((name) -> true);
}
origin: com.github.groupon.monsoon/monsoon-expr

public RegexMatchPredicate(TimeSeriesMetricExpression expr, String regex) {
  match_ = Pattern.compile(regex).asPredicate();
  expr_ = expr;
  regex_ = regex;
}
origin: stackoverflow.com

 try(Stream<String> lines=Files.lines(pathToYourFile)) {
  ChunkSpliterator.toChunks(
    lines,
    Pattern.compile("^\\Q$$$$\\E$").asPredicate(),
    false)
  /* chain your stream operations, e.g.
  .forEach(s -> { s.forEach(System.out::print); System.out.println(); })
   */;
}
origin: com.github.groupon.monsoon/monsoon-expr

public RegexMatch(@NonNull String regex, @NonNull Optional<IdentifierMatch> successor) {
  this.regex = regex;
  this.match = Pattern.compile(regex).asPredicate();
  this.successor = successor;
}
origin: jpos/jPOS-EE

private List<String> getFiles(File dir) {
  return Arrays.stream(dir.list())
      .filter(filePattern.asPredicate())
      .sorted(String::compareTo)
      .collect(Collectors.toList());
}
private List<String> getFilesReversed(File dir) {
origin: org.apache.jmeter/ApacheJMeter_jms

  /**
   * 
   */
  protected void configureIsReconnectErrorCode() {
    String regex = StringUtils.trimToEmpty(getReconnectionErrorCodes());
    if (regex.isEmpty()) {
      isReconnectErrorCode = e -> false;
    } else {
      isReconnectErrorCode = Pattern.compile(regex).asPredicate();
    }
  }
}
origin: org.apereo.cas/cas-server-core-services-api

  private boolean requiredAttributeFound(final String attributeName, final Map<String, Object> principalAttributes, final Map<String, Set<String>> requiredAttributes) {
    val values = requiredAttributes.get(attributeName);
    val availableValues = CollectionUtils.toCollection(principalAttributes.get(attributeName));
    val pattern = RegexUtils.concatenate(values, this.caseInsensitive);
    LOGGER.debug("Checking [{}] against [{}] with pattern [{}] for attribute [{}]", values, availableValues, pattern, attributeName);
    if (pattern != RegexUtils.MATCH_NOTHING_PATTERN) {
      return availableValues.stream().map(Object::toString).anyMatch(pattern.asPredicate());
    }
    return availableValues.stream().anyMatch(values::contains);
  }
}
origin: net.paissad.tools.reqcoco.parser/reqcoco-parser-simple

private Collection<Requirement> parseSingleFile(final ReqDeclTagConfig declTagConfig, final Path resourcePath) throws IOException {
  try (final Stream<String> lines = Files.lines(resourcePath, StandardCharsets.UTF_8)) {
    final Set<Requirement> declaredRequirements = new HashSet<>();
    final Predicate<String> lineContainsRequirementPredicate = Pattern.compile(declTagConfig.getCompleteRegex()).asPredicate();
    lines.parallel().filter(lineContainsRequirementPredicate).forEach(line -> declaredRequirements.addAll(getRequirementsFromString(declTagConfig, line)));
    return declaredRequirements;
  }
}
origin: NyaaCat/RPGItems-reloaded

public ItemGroup(String name, int uid, String regex, CommandSender author) {
  this.name = name;
  this.uid = uid;
  this.regex = regex;
  this.setAuthor(author instanceof Player ? ((Player) author).getUniqueId().toString() : plugin.cfg.defaultAuthor);
  if (!Strings.isNullOrEmpty(regex)) {
    Pattern p = Pattern.compile(regex);
    setItems(ItemManager.itemNames().stream().filter(p.asPredicate()).map(ItemManager::getItemByName).collect(Collectors.toSet()));
    setItemUids(items.stream().map(RPGItem::getUid).collect(Collectors.toSet()));
  }
}
origin: stackoverflow.com

 TextArea ta = new TextArea();
final Pattern binary = Pattern.compile("^[01]*$");
final Predicate<String> tester = binary.asPredicate();
ta.setTextFormatter(new TextFormatter<>(change -> {
  if (!tester.test(change.getControlNewText())) {
    return null;
  }
  return change;
}));
origin: org.apache.james/james-server-mailets

@Override
public boolean doTest(Mail mail) throws MessagingException, IOException {
  return Stream
    .concat(getMessageSubjects(mail), getMessageBodies(mail.getMessage()))
    .anyMatch(pattern.asPredicate());
}
java.util.regexPatternasPredicate

Popular methods of Pattern

  • matcher
    Creates a matcher that will match the given input against this pattern.
  • compile
  • quote
    Returns a literal pattern String for the specifiedString.This method produces a String that can be u
  • split
    Splits the given input sequence around matches of this pattern. The array returned by this method co
  • pattern
  • matches
  • toString
    Returns the string representation of this pattern. This is the regular expression from which this pa
  • flags
    Returns this pattern's match flags.
  • splitAsStream
  • <init>
    This private constructor is used to create all Patterns. The pattern string and match flags are all
  • closeImpl
  • compileImpl
  • closeImpl,
  • compileImpl,
  • closure,
  • error,
  • escape,
  • RemoveQEQuoting,
  • accept,
  • addFlag,
  • append

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now