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:com.anathema_roguelike.characters.abilities.targetingstrategies.ranges.Range.java

public Collection<Character> getTargets(final Character character, Predicate<Character> predicate) {

    Predicate<Character> visible = new Predicate<Character>() {

        @Override//from   ww  w.  j a  va  2s  .  c o m
        public boolean apply(Character target) {
            return target.isVisibleTo(character);
        }
    };

    return getTargetsInRange(character, Predicates.and(visible, predicate));
}

From source file:org.caleydo.view.enroute.correlation.fisher.FishersSelectDataCellPage.java

@Override
public void pageChanged(PageChangedEvent event) {
    FishersExactTestWizard wizard = (FishersExactTestWizard) getWizard();
    if (event.getSelectedPage() == getNextPage()) {

        wizard.setPageInfo(this, info, classificationWidget.getClassifier());
    } else if (event.getSelectedPage() == this) {
        if (wizard.isFirstPage(this)) {
            UpdateDataCellSelectionValidatorEvent e = new UpdateDataCellSelectionValidatorEvent(
                    CellSelectionValidators.nonEmptyCellValidator());
            EventPublisher.trigger(e);/*from w  w  w .j a  v  a  2s.  com*/
        } else {
            if (info != null) {
                if (!CellSelectionValidators.overlappingSamplesValidator(wizard.getInfo1()).apply(info)) {

                    info = null;
                    classificationGroup.setVisible(false);
                    dataCellInfoWidget.updateInfo(null);
                    instructionsLabel.setText(initialInstruction);
                    if (restrictionLabel != null) {
                        restrictionLabel.setVisible(true);
                        restrictionLabel.setText(selectionRestrictionText);
                    }
                    getWizard().getContainer().updateButtons();

                    EventPublisher
                            .trigger(new ShowOverlayEvent(null, null, getWizard().getStartingPage() == this));
                }
            }

            UpdateDataCellSelectionValidatorEvent e = new UpdateDataCellSelectionValidatorEvent(
                    Predicates.and(CellSelectionValidators.nonEmptyCellValidator(),
                            CellSelectionValidators.overlappingSamplesValidator(wizard.getInfo1())));
            EventPublisher.trigger(e);
        }

    }

}

From source file:org.apache.aurora.common.args.ArgFilters.java

/**
 * Creates a filter that selects a single {@literal @CmdLine} {@link Arg}.
 *
 * @param clazz The class that declares the command line arg to be selected.
 * @param name The {@link CmdLine#name()} of the arg to select.
 * @return A filter that selects a single specified command line arg.
 *//*from w ww .  ja  v  a 2s  .c o m*/
public static Predicate<Field> selectCmdLineArg(Class<?> clazz, final String name) {
    MorePreconditions.checkNotBlank(name);
    return Predicates.and(selectClass(clazz), field -> {
        return field.getAnnotation(CmdLine.class).name().equals(name);
    });
}

From source file:com.eucalyptus.cloud.CloudMetadatas.java

public static <T extends CloudMetadata> Predicate<T> filterPrivilegesById(
        final Collection<String> requestedIdentifiers) {
    return Predicates.and(filterById(requestedIdentifiers), RestrictedTypes.filterPrivileged());

}

From source file:com.facebook.litho.testing.viewtree.ViewPredicates.java

public static Predicate<View> hasVisibleMatchingText(final String text) {
    return Predicates.and(isVisible(), matchesText(text));
}

From source file:com.github.jeluard.guayaba.base.PartialFunctions.java

/**
 * Execute result of execution of first {@link PartialFunction} whose return type matches specified `outputType`.
 *
 * @param <I>// w ww .j  a v  a  2 s  .com
 * @param <O>
 * @param <P>
 * @param <PF>
 * @param partialFunctions
 * @param type
 * @param element
 * @return result of first matching {@link PartialFunction}
 */
public static <I, O, P extends O, PF extends PartialFunction<I, ? extends O>> Optional<PF> tryFindForOutput(
        final Iterable<PF> partialFunctions, final Class<? extends P> type, final I element) {
    Preconditions.checkNotNull(partialFunctions, "null partialFunctions");
    Preconditions.checkNotNull(element, "null element");

    return Iterables.tryFind(partialFunctions,
            Predicates.and(new DefinedPredicate(element), new AssignableOutputPredicate(type)));
}

From source file:li.klass.fhem.ui.FileDialog.java

private void loadFileList(File path) {
    this.currentPath = path;

    Predicate<File> predicate = new Predicate<File>() {
        @Override/*from www. ja v  a  2 s  .c o  m*/
        public boolean apply(File sel) {
            if (!sel.canRead()) {
                return false;
            } else if (selectDirectoryOption) {
                return sel.isDirectory();
            } else {
                boolean endsWith = fileEndsWith == null
                        || sel.getName().toLowerCase(Locale.getDefault()).endsWith(fileEndsWith);
                return endsWith || sel.isDirectory();
            }
        }
    };
    if (fileFilter.isPresent()) {
        predicate = Predicates.and(predicate, fileFilter.get());
    }

    List<String> result = newArrayList();
    if (path.exists()) {
        if (path.getParentFile() != null)
            result.add(PARENT_DIR);
        final Predicate<File> finalPredicate = predicate;
        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String filename) {
                return finalPredicate.apply(new File(dir, filename));
            }
        };
        String[] files = path.list(filter);

        if (files != null) {
            Collections.addAll(result, files);
        }

        Collections.sort(result);
    }
    fileList = result.toArray(new String[result.size()]);
}

From source file:com.anathema_roguelike.characters.abilities.targetingstrategies.ranges.Range.java

public Collection<Character> getVisibleTargets(final Character character, Predicate<Character> predicate) {
    return getTargets(character, Predicates.and(predicate, new Predicate<Character>() {

        @Override/*ww w. j  a  v  a 2s  .c o m*/
        public boolean apply(Character target) {
            return target.isVisibleTo(character);
        }

    }));
}

From source file:com.codereligion.cherry.reflect.BeanIntrospections.java

/**
 * Retrieves a {@link Set} of writeable and readable properties of the given {@code type}. This includes all properties which have a public setter.
 *
 * @param type the {@link Class} to get the writeable and readable properties for
 * @return a {@link Set} of {@link PropertyDescriptor}s
 * @throws NullPointerException     when the given {@code type} is {@code null}
 * @throws IllegalArgumentException when the given {@code type} can not be introspected
 *//*from   ww w .  j ava 2  s  .c o  m*/
public static Set<PropertyDescriptor> getWriteableAndReadableProperties(final Class<?> type) {
    checkNotNull(type, TYPE_MUST_NOT_BE_NULL);
    return getProperties(type, Predicates.and(HasReadMethod.INSTANCE, HasWriteMethod.INSTANCE));
}

From source file:org.apache.aurora.scheduler.resources.ResourceManager.java

/**
 * Gets non-Mesos-revocable offer resources.
 *
 * @param offer Offer to get resources from.
 * @return Non-Mesos-revocable offer resources.
 *//*from  w w w.jav a  2s .co m*/
public static Iterable<Resource> getNonRevocableOfferResources(Offer offer) {
    return Iterables.filter(offer.getResourcesList(), Predicates.and(SUPPORTED_RESOURCE, NON_REVOCABLE));
}