All Downloads are FREE. Search and download functionalities are using the official Maven repository.

su.nlq.prometheus.jmx.ExcludeQuery Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
package su.nlq.prometheus.jmx;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.management.*;
import java.util.Collection;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public final class ExcludeQuery implements QueryExp {
  private final @NotNull Collection patterns;

  public ExcludeQuery(@NotNull Collection patterns) {
    this.patterns = patterns.stream().map(Pattern::compile).collect(Collectors.toList());
  }

  @SuppressWarnings("MethodWithTooExceptionsDeclared")
  @Override
  public boolean apply(@Nullable ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
    return name != null && patterns.stream().noneMatch(pattern -> pattern.matcher(name.getCanonicalName()).matches());
  }

  @Override
  public void setMBeanServer(@Nullable MBeanServer mBeanServer) {
    //do nothing
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy