Example usage for com.google.common.base Predicates and

List of usage examples for com.google.common.base Predicates and

Introduction

In this page you can find the example usage for com.google.common.base Predicates and.

Prototype

public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) 

Source Link

Document

Returns a predicate that evaluates to true if both of its components evaluate to true .

Usage

From source file:pl.nort.dayoneevernote.filter.NoteFilterBeansConfig.java

@Bean
@Primary/*from   w w  w  .java2 s .  c o m*/
public Predicate<Note> defaultFilterChain() {
    NoteFilter titleMatchPredicate = new TitleMatchPredicate("[1-2][0-9]{3}/[01][0-9]/[0-3][0-9].*");
    NoteFilter labelMatchPredicate = new LabelMatchPredicate("First notebook");

    return Predicates.and(titleMatchPredicate, labelMatchPredicate);
}

From source file:com.ssm.config.SwaggerConfig.java

private Predicate<String> paths() {
    return Predicates.and(PathSelectors.regex("/.*"), Predicates.not(PathSelectors.regex("/error")));
}

From source file:io.gravitee.gateway.core.reactor.RouteMatcher.java

public Api match(final Request request) {
    // Matching rules:
    // - Context Path
    // - Virtual host (using HOST header)
    return FluentIterable.from(registry.listAll()).firstMatch(Predicates.and(new Predicate<Api>() {
        @Override//w ww  .  jav a 2 s. co  m
        public boolean apply(final Api api) {
            return request.path().startsWith(api.getPublicURI().getPath());
        }
    }, new Predicate<Api>() {
        @Override
        public boolean apply(Api api) {
            return api.getPublicURI().getHost().equalsIgnoreCase(request.headers().get(HttpHeaders.HOST));
        }
    })).orNull();
}

From source file:org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForTypeLegacy.java

protected final static Predicate<Throwable> ofTypeIncluding(final Class<? extends Throwable> exceptionType,
        final String... messages) {
    return Predicates.and(ofType(exceptionType), including(messages));
}

From source file:org.jetbrains.k2js.analyze.TopDownAnalyzerFacadeForJS.java

@NotNull
public static AnalyzeExhaust analyzeFiles(@NotNull Collection<JetFile> files,
        @NotNull Predicate<PsiFile> filesToAnalyzeCompletely, @NotNull Config config) {
    Project project = config.getProject();

    ModuleDescriptorImpl owner = createJsModule("<module>");

    Predicate<PsiFile> completely = Predicates.and(notLibFiles(config.getLibFiles()), filesToAnalyzeCompletely);

    GlobalContextImpl globalContext = ContextPackage.GlobalContext();
    TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.create(
            globalContext.getStorageManager(), globalContext.getExceptionTracker(), completely, false, false);

    owner.addDependencyOnModule(owner);/*from ww w. ja v a 2 s  . co m*/
    owner.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
    ModuleDescriptor libraryModule = config.getLibraryModule();
    if (libraryModule != null) {
        owner.addDependencyOnModule((ModuleDescriptorImpl) libraryModule); // "import" analyzed library module
    }
    owner.seal();

    BindingContext libraryContext = config.getLibraryContext();
    BindingTrace trace = libraryContext == null ? new BindingTraceContext()
            : new DelegatingBindingTrace(libraryContext, "trace with preanalyzed library");
    InjectorForTopDownAnalyzerForJs injector = new InjectorForTopDownAnalyzerForJs(project,
            topDownAnalysisParameters, trace, owner);
    try {
        Collection<JetFile> allFiles = libraryModule != null ? files : Config.withJsLibAdded(files, config);
        injector.getTopDownAnalyzer().analyzeFiles(topDownAnalysisParameters, allFiles);
        return AnalyzeExhaust.success(trace.getBindingContext(), owner);
    } finally {
        injector.destroy();
    }
}

From source file:com.github.autermann.yaml.YamlNodes.java

/**
 * Creates a {@link Predicate} for {@link YamlNode}s that are not
 * {@code null} or missing.//from w  w  w. j ava 2 s.  c  o m
 *
 * @return the predicate
 */
public static Predicate<YamlNode> notNullOrMissing() {
    return Predicates.and(notNull(), notMissing());
}

From source file:org.apache.wicket.atmosphere.ListenerEventSubscription.java

/**
 * Construct.//w w w. j a v a  2 s  .  c o m
 * 
 * @param component
 * @param behavior
 * @param method
 */
public ListenerEventSubscription(AtmosphereEventSubscription eventListener, Predicate filter, Class eventType) {
    this.eventListener = eventListener;
    this.filter = Predicates.and(Predicates.instanceOf(eventType), filter);
}

From source file:com.enerbos.cloud.resource.config.SwaggerConfig.java

@Bean
public Docket swaggerSpringMvcPlugin() {
    return new Docket(DocumentationType.SWAGGER_2)
            .useDefaultResponseMessages(false).apiInfo(apiInfo()).select().paths(Predicates
                    .and(Predicates.not(PathSelectors.regex("/error.*")), PathSelectors.regex("/auth/.*")))
            .build();//from w  ww .  j  a v a2  s .co  m
}

From source file:org.deephacks.tools4j.support.test.Criteria.java

@SuppressWarnings("unchecked")
public Criteria and(Predicate predicate) {
    if (!Criteria.class.isInstance(predicate)) {
        predicate = new PredicateProxy(fieldName, predicate);
    }//from ww  w. jav  a  2s  .c om
    p = Predicates.and(p, predicate);
    return this;
}

From source file:com.technophobia.substeps.runner.runtime.PredicatedClassLocator.java

public Iterator<Class<?>> fromPath(final String path) {
    final File directory = new File(path);
    final Iterator<File> files = FileUtils.iterateFiles(directory, new String[] { "class" }, true);
    final Iterator<Class<?>> unsafeTransformedClasses = Iterators.transform(files, classLoader);

    return Iterators.filter(unsafeTransformedClasses, Predicates.and(Predicates.notNull(), predicate));
}