Example usage for com.google.common.collect Sets filter

List of usage examples for com.google.common.collect Sets filter

Introduction

In this page you can find the example usage for com.google.common.collect Sets filter.

Prototype

@GwtIncompatible("NavigableSet")
@SuppressWarnings("unchecked")
@CheckReturnValue
public static <E> NavigableSet<E> filter(NavigableSet<E> unfiltered, Predicate<? super E> predicate) 

Source Link

Document

Returns the elements of a NavigableSet , unfiltered , that satisfy a predicate.

Usage

From source file:com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement.java

/**
 * This function clears all REIL temporary registers from a Set of registers.
 * /*from www . j av a  2s . co m*/
 * @param registerSet The Set of registers where the REIL temporary registers are cleared from.
 */
private static void clearTemporaryRegisters(final Set<String> registerSet) {
    Sets.filter(registerSet, new Predicate<String>() {
        @Override
        public boolean apply(final String register) {
            return ReilHelpers.isTemporaryRegister(register);
        }
    }).clear();
}

From source file:com.proofpoint.cloudmanagement.service.inventoryclient.MockInventoryServer.java

private Map<String, String> systemWithWithPredicate(Predicate<Map<String, String>> predicate) {
    Preconditions.checkNotNull(predicate);

    Set<Map<String, String>> filtered = Sets.filter(inventory, predicate);

    if (filtered.size() > 1) {
        throw new IllegalStateException("Too many objects matching predicate in set");
    }/*from w  w w  . j  av  a 2 s.  c  om*/

    if (filtered.isEmpty()) {
        return null;
    }

    return filtered.iterator().next();
}

From source file:org.mitre.oauth2.service.impl.DefaultSystemScopeService.java

@Override
public Set<SystemScope> getDefaults() {
    return Sets.filter(getAll(), isDefault);
}

From source file:brooklyn.config.render.RendererHints.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private static <T extends Hint> Set<T> _getHintsFor(Object element, Class<T> optionalHintSuperClass) {
    Set<Hint<?>> found = ImmutableSet.copyOf(registry.get(element));
    if (found.isEmpty() && element instanceof Class && !Object.class.equals(element)) {
        // try superclasses of the element; this seems overkill for the main use case, Entity;
        // (other classes registered are typically final)
        found = (Set<Hint<?>>) _getHintsFor(((Class) element).getSuperclass(), optionalHintSuperClass);
        if (found.isEmpty()) {
            for (Class<?> parentInterface : ((Class) element).getInterfaces()) {
                found = (Set<Hint<?>>) _getHintsFor(parentInterface, optionalHintSuperClass);
                if (!found.isEmpty())
                    break;
            }/*from w  w w .j  a  va 2s. c  om*/
        }
    }
    if (optionalHintSuperClass != null) {
        return (Set<T>) Sets.filter(found, Predicates.instanceOf(optionalHintSuperClass));
    } else {
        return (Set<T>) found;
    }
}

From source file:com.payu.ratel.server.InMemoryDiscoveryServer.java

public Set<ServiceDescriptor> getServiceInstances(final String serviceName) {
    return Sets.filter(services, new Predicate<ServiceDescriptor>() {
        @Override//w w  w . ja  va  2s . c o m
        public boolean apply(ServiceDescriptor desc) {
            return desc.getName().equals(serviceName);
        }
    });
}

From source file:dynamicrefactoring.domain.AbstractRefactoringsCatalog.java

/**
 * Obtienen las refactorizaciones que pertenecen a una categora.
 * /*w  ww  .  j  av  a  2s. com*/
 * @param classification
 *            nombre de la clasificacin
 * @param categoryName
 *            nombre de la categora
 * 
 * @return conjunto de refactorizaciones que pertenecen a la categora
 */
@Override
public final Set<DynamicRefactoringDefinition> getRefactoringBelongingTo(String classification,
        String categoryName) {
    return new HashSet<DynamicRefactoringDefinition>(Sets.filter(getAllRefactorings(),
            new CategoryCondition<DynamicRefactoringDefinition>(classification, categoryName)));
}

From source file:com.adition.middleware.dbt.orientdb.bridge.core.EntityAnalyzer.java

/**
 * Method filters only those fields what are not annotated with certain annotation
 * @param initialSet//from   w w w .j  a  v a 2  s  .c  o m
 * @param annotation
 * @return 
 */
private Set<Field> filterNegative(Set<Field> initialSet, Class<? extends Annotation> annotation) {
    final Set<Field> filtered = Sets.filter(initialSet, new Predicate<Field>() {
        @Override
        public boolean apply(Field field) {
            return !field.isAnnotationPresent(annotation);
        }
    });
    return filtered;
}

From source file:org.mitre.oauth2.service.impl.DefaultSystemScopeService.java

@Override
public Set<SystemScope> getDynReg() {
    return Sets.filter(getAll(), isDynReg);
}

From source file:com.censoredsoftware.infractions.bukkit.origin.Origin.java

/**
 * Set of Infractions with data from this Origin.
 *
 * @return Infractions.//from   ww  w .  jav  a  2s .  c  om
 */
public Set<Infraction> getContributedInfractions() {
    final Origin origin = this;
    return Sets.filter(Infractions.allInfractions(), new Predicate<Infraction>() {
        @Override
        public boolean apply(Infraction infraction) {
            return Iterables.any(infraction.getEvidence(), new Predicate<Evidence>() {
                @Override
                public boolean apply(Evidence evidence) {
                    return origin.equals(evidence.getOrigin());
                }
            });
        }
    });
}

From source file:gov.nih.nci.caarray.domain.file.FileTypeRegistryImpl.java

/**
 * {@inheritDoc}/*  w w  w. jav  a  2 s . c o  m*/
 */
@Override
public Set<FileType> getMageTabTypes() {
    return Sets.filter(this.types, new Predicate<FileType>() {
        @Override
        public boolean apply(FileType ft) {
            return ft.isMageTab();
        }
    });
}