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:org.nickelproject.util.testUtil.ClasspathUtil.java

/**
 * Find classes annotated with one or more of the arguments.
 *
 * @param pAnnotations/*from   w ww .jav a  2  s  . c  o m*/
 *            The annotations to look for
 * @return An iterable of class names
 */
public static Iterable<String> getAnnotatedClasses(final Class<?>... pAnnotations) {
    final String[] vAnnotationNames = new String[pAnnotations.length];
    for (int i = 0; i < vAnnotationNames.length; i++) {
        vAnnotationNames[i] = pAnnotations[i].getName();
    }
    final Iterable<String> vAllClasses = Iterables.transform(getResourcesOnClassPath("class"),
            new Function<String, String>() {
                @Override
                public String apply(final String pInput) {
                    return FilenameUtils.getBaseName(pInput);
                }
            });
    return Iterables.filter(vAllClasses, Predicates.and(getIsConcrete(), new HasAnnotation(vAnnotationNames)));
}

From source file:org.estatio.dom.lease.contributed.LeaseContributions.java

private static Predicate<AgreementRole> whetherCurrentAndAgreementTypeIs(final AgreementType agreementType) {
    return Predicates.and(AgreementRole.Predicates.whetherAgreementTypeIs(agreementType),
            WithInterval.Predicates.<AgreementRole>whetherCurrentIs(true));
}

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

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

    final ModuleDescriptor owner = new ModuleDescriptor(Name.special("<module>"));

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

    TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters(completely, false,
            false, Collections.<AnalyzerScriptParameter>emptyList());

    BindingContext libraryBindingContext = config.getLibraryBindingContext();
    BindingTrace trace = libraryBindingContext == null ? new ObservableBindingTrace(new BindingTraceContext())
            : new DelegatingBindingTrace(libraryBindingContext, "trace for analyzing library in js");
    InjectorForTopDownAnalyzerForJs injector = new InjectorForTopDownAnalyzerForJs(project,
            topDownAnalysisParameters, trace, owner, new JsConfiguration(project, libraryBindingContext));
    try {/*from  w  w  w .java 2 s.com*/
        Collection<JetFile> allFiles = libraryBindingContext != null ? files
                : Config.withJsLibAdded(files, config);
        injector.getTopDownAnalyzer().analyzeFiles(allFiles, Collections.<AnalyzerScriptParameter>emptyList());
        BodiesResolveContext bodiesResolveContext = storeContextForBodiesResolve
                ? new CachedBodiesResolveContext(injector.getTopDownAnalysisContext())
                : null;
        return AnalyzeExhaust.success(trace.getBindingContext(), bodiesResolveContext,
                injector.getModuleConfiguration());
    } finally {
        injector.destroy();
    }
}

From source file:org.n52.sos.request.operator.TransactionalRequestChecker.java

@SuppressWarnings("unchecked")
public TransactionalRequestChecker(TransactionalSecurityConfiguration config) {
    this.predicate = Predicates.and(createIpAdressPredicate(config), createTokenPredicate(config));
}

From source file:org.obeonetwork.dsl.uml2.design.tests.automation.common.ModelChangeRecorder.java

public Iterable<EObject> attachedObjects() {
    return Iterables.concat(Iterables.transform(
            Iterables.filter(changes, Predicates.and(Notifications.containmentRef, Notifications.addition)),
            Notifications.toObjectValue));
}

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

/**
 * Construct.//from   w w  w.  j  a v  a2  s .  co m
 * 
 * @param component
 * @param behavior
 * @param method
 */
public MethodEventSubscription(Component component, Behavior behavior, Method method) {
    componentPath = component.getPageRelativePath();
    behaviorIndex = behavior == null ? null : component.getBehaviorId(behavior);
    Class<?> eventType = method.getParameterTypes()[1];
    Subscribe subscribe = method.getAnnotation(Subscribe.class);
    filter = Predicates.and(Predicates.instanceOf(eventType), createFilter(subscribe.filter()));
    contextAwareFilter = createFilter(subscribe.contextAwareFilter());
    methodName = method.getName();
}

From source file:org.caleydo.view.enroute.correlation.wilcoxon.WilcoxonManualSourceDataCellPage.java

@Override
public void pageChanged(PageChangedEvent event) {
    if (event.getSelectedPage() == getNextPage()) {
        WilcoxonRankSumTestWizard wizard = (WilcoxonRankSumTestWizard) getWizard();
        wizard.setSourceInfo(info);//from   w w  w  . jav  a 2s. c o  m
        IDataClassifier classifier = classificationWidget.getClassifier();
        wizard.setSourceClassifier(classifier);

    } else if (event.getSelectedPage() == this) {
        Predicate<DataCellInfo> validator = Predicates.and(CellSelectionValidators.nonEmptyCellValidator(),
                CellSelectionValidators.numericalValuesValidator());
        UpdateDataCellSelectionValidatorEvent e = new UpdateDataCellSelectionValidatorEvent(validator);
        EventPublisher.trigger(e);
    }

}

From source file:brooklyn.location.access.PortForwardManagerLocationResolver.java

@Override
public Location newLocationFromString(Map locationFlags, String spec,
        brooklyn.location.LocationRegistry registry) {
    ConfigBag config = extractConfig(locationFlags, spec, registry);
    Map globalProperties = registry.getProperties();
    String namedLocation = (String) locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
    String scope = config.get(PortForwardManager.SCOPE);

    Optional<Location> result = Iterables.tryFind(managementContext.getLocationManager().getLocations(),
            Predicates.and(Predicates.instanceOf(PortForwardManager.class),
                    LocationPredicates.configEqualTo(PortForwardManager.SCOPE, scope)));

    if (result.isPresent()) {
        return result.get();
    } else {/*from  www .  ja v a  2s  .  co  m*/
        PortForwardManager loc = managementContext.getLocationManager()
                .createLocation(LocationSpec.create(PortForwardManagerImpl.class)
                        .configure(config.getAllConfig()).configure(LocationConfigUtils
                                .finalAndOriginalSpecs(spec, locationFlags, globalProperties, namedLocation)));

        if (LOG.isDebugEnabled())
            LOG.debug("Created " + loc + " for scope " + scope);
        return loc;
    }
}

From source file:org.caleydo.view.enroute.correlation.wilcoxon.WilcoxonAutoSourceDataCellPage.java

@Override
public void pageChanged(PageChangedEvent event) {
    if (event.getSelectedPage() == getNextPage()) {
        WilcoxonRankSumTestWizard wizard = (WilcoxonRankSumTestWizard) getWizard();
        wizard.setSourceInfo(info);//from   w  ww . j a  va  2  s . co m
    } else if (event.getSelectedPage() == this) {
        Predicate<DataCellInfo> validator = Predicates.and(CellSelectionValidators.nonEmptyCellValidator(),
                CellSelectionValidators.numericalValuesValidator());

        UpdateDataCellSelectionValidatorEvent e = new UpdateDataCellSelectionValidatorEvent(validator);
        EventPublisher.trigger(e);
    }
}

From source file:org.eclipse.buildship.ui.view.task.TaskNodeViewerFilter.java

private static Predicate<TaskNode> createTaskNodeFilter(final TaskViewState state) {
    Predicate<TaskNode> projectTasks = new Predicate<TaskNode>() {

        @Override//  w w w .j a v  a2s .  c om
        public boolean apply(TaskNode taskNode) {
            return state.isProjectTasksVisible()
                    && taskNode.getType() == TaskNode.TaskNodeType.PROJECT_TASK_NODE;
        }
    };

    Predicate<TaskNode> taskSelectors = new Predicate<TaskNode>() {

        @Override
        public boolean apply(TaskNode taskNode) {
            return state.isTaskSelectorsVisible()
                    && taskNode.getType() == TaskNode.TaskNodeType.TASK_SELECTOR_NODE;
        }
    };

    Predicate<TaskNode> privateTasks = new Predicate<TaskNode>() {

        @Override
        public boolean apply(TaskNode taskNode) {
            return state.isPrivateTasksVisible() || taskNode.isPublic();
        }
    };

    return Predicates.and(Predicates.or(projectTasks, taskSelectors), privateTasks);
}