List of usage examples for com.google.common.collect Collections2 filter
@CheckReturnValue public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate)
From source file:net.sourceforge.atunes.kernel.actions.RepairGenresAction.java
/** * Returns files without genre/*from w w w . j a v a 2s . co m*/ * @param audioFiles * @return */ private Collection<ILocalAudioObject> getFilesWithEmptyGenre(final Collection<ILocalAudioObject> audioFiles) { return Collections2.filter(audioFiles, new FilesWithEmptyGenre()); }
From source file:net.shibboleth.idp.profile.interceptor.impl.PopulateProfileInterceptorContext.java
/** * Set the flows available for possible use. * /* w w w . j a va2s. co m*/ * @param flows the flows available for possible use */ public void setAvailableFlows( @Nonnull @NonnullElements final Collection<ProfileInterceptorFlowDescriptor> flows) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(flows, "Flow collection cannot be null"); availableFlows = new ArrayList<>(Collections2.filter(flows, Predicates.notNull())); }
From source file:fi.vm.sade.osoitepalvelu.service.mock.KoodistoServiceRouteMock.java
@Override public List<KoodiDto> findKooditKoodistonVersiolleTyyppilla(final KoodistoDto.KoodistoTyyppi koodistoTyyppi, final long versio) { return collect(Collections2.filter(koodis.keySet(), new Predicate<KoodistoVersioDto>() { public boolean apply(KoodistoVersioDto input) { return input.getVersio() == versio && input.getKoodistoTyyppi() == koodistoTyyppi; }/*w w w . j av a 2 s.co m*/ })); }
From source file:net.shibboleth.idp.oidc.config.login.LoginConfiguration.java
/** * Sets default authentication methods.// w w w .ja v a 2 s.c om * * @param contexts the contexts */ public void setDefaultAuthenticationMethods( @Nonnull @NonnullElements final List<AuthnContextClassRefPrincipal> contexts) { Constraint.isNotNull(contexts, "List of contexts cannot be null"); this.defaultAuthenticationContexts = new ArrayList(Collections2.filter(contexts, Predicates.notNull())); }
From source file:com.codetroopers.maven.mergeprops.MergeProperty.java
private static void checkCountMismatch(final Map<String, Properties> propertiesMap, final Merge merge, final Map<String, Integer> localeSizeMap) throws MojoFailureException { //if we got the same numbers of keys, the set will flatten every values if (shouldFailIfNoMatchFromProperty() && merge.getFailOnCountMismatch() && new HashSet<Integer>(localeSizeMap.values()).size() != 1) { final HashMultiset<String> multiset = HashMultiset.create(); for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) { multiset.addAll(Maps.fromProperties(entry.getValue()).keySet()); }/*from ww w .j ava 2 s . c o m*/ final int bundlesAmount = propertiesMap.keySet().size(); final Set<String> lonelyKeys = Sets.newHashSet(Collections2.filter(multiset, new Predicate<String>() { @Override public boolean apply(final String input) { return multiset.count(input) != bundlesAmount; } })); throw new MojoFailureException(lonelyKeys, "Invalid property count for file : " + merge.getTarget(), "Lonely keys are : \n" + Joiner.on("\n").join(lonelyKeys)); } }
From source file:org.ow2.play.governance.service.TopicRegistryService.java
@Override public boolean isActive(Topic topic) throws GovernanceExeption { return Collections2.filter(getProperties(topic), new Predicate<Metadata>() { public boolean apply(Metadata md) { return (md != null && md.getName().equals(Constants.TOPIC_ACTIVE) && md.getData().size() == 1 && md.getData().get(0).equals(Constants.BOOLEAN_TRUE)); }/* w w w.j av a2 s. c o m*/ }).size() >= 1; }
From source file:org.xacml4j.v30.AttributeContainer.java
/** * Finds all instance of {@link Attribute} with * {@link Attribute#isIncludeInResult()} returning * {@code true}//w w w . j a v a2 s. c o m * * @return a collection of {@link Attribute} * instances */ public Collection<Attribute> getIncludeInResultAttributes() { return Collections2.filter(attributes.values(), new Predicate<Attribute>() { @Override public boolean apply(Attribute attr) { return attr.isIncludeInResult(); } }); }
From source file:org.chtijbug.drools.logging.SessionExecution.java
public java.util.Collection<Fact> getFactsByType(final FactType factType) { if (this.getFacts().isEmpty()) return Lists.newArrayList(); return Collections2.filter(this.getFacts(), new Predicate<Fact>() { @Override/*from ww w . jav a 2 s. c om*/ public boolean apply(Fact fact) { return fact.getFactType().equals(factType); } }); }
From source file:org.pau.assetmanager.business.HistoricalStockValuesBusiness.java
public static void saveOrUpdate(final String symbol, final Integer year) { // collect data from Internet final Collection<HistoricalStockValue> historicalValuesInInternet = HistoricalStocksValuesDownloader .getHistoricalStockValuesForYear(symbol, year); // find the values in the database for the given symbol and year String query = "select historicalStockValue from HistoricalStockValue historicalStockValue where year = :year and symbol = :symbol"; final List<HistoricalStockValue> historicalValuesForSymbolInCurrentYearInDatabase = DaoFunction .<HistoricalStockValue>querySimpleListFunction("symbol", symbol, "year", year).apply(query); Collection<HistoricalStockValue> historicalValuesInInternetButNotInDatabase = Collections2 .filter(historicalValuesInInternet, new Predicate<HistoricalStockValue>() { @Override//from w w w . j a v a 2s . c o m public boolean apply(HistoricalStockValue input) { return !historicalValuesForSymbolInCurrentYearInDatabase.contains(input); } }); // store the values that are not in database DaoFunction<Collection<HistoricalStockValue>, Void> saveFunction = new DaoFunction<Collection<HistoricalStockValue>, Void>() { @Override protected Void doInTransaction(EntityManager entityManager, Collection<HistoricalStockValue> historicalValuesInInternetButNotInDatabase) { for (HistoricalStockValue currentHistoricalValuesNotInDatabase : historicalValuesInInternetButNotInDatabase) { entityManager.persist(currentHistoricalValuesNotInDatabase); } return null; } }; saveFunction.apply(historicalValuesInInternetButNotInDatabase); for (HistoricalStockValue historicalStockValueInDatabase : historicalValuesForSymbolInCurrentYearInDatabase) { for (HistoricalStockValue historicalStockValueInInternet : historicalValuesInInternet) { if (historicalStockValueInDatabase.equals(historicalStockValueInInternet)) { historicalStockValueInDatabase .setNumericalValue(historicalStockValueInInternet.getNumericalValue()); } } } // merge the changes for the values in database DaoFunction<Collection<HistoricalStockValue>, Void> updateFunction = new DaoFunction<Collection<HistoricalStockValue>, Void>() { @Override protected Void doInTransaction(EntityManager entityManager, Collection<HistoricalStockValue> historicalValuesForSymbolInCurrentYearInDatabase) { for (HistoricalStockValue currentHistoricalValuesNotInDatabase : historicalValuesForSymbolInCurrentYearInDatabase) { entityManager.merge(currentHistoricalValuesNotInDatabase); } return null; } }; updateFunction.apply(historicalValuesForSymbolInCurrentYearInDatabase); }
From source file:net.shibboleth.idp.authn.impl.PopulateAuthenticationContext.java
/** * Set the flows available for possible use. * /* ww w. j a v a 2 s . c om*/ * @param flows the flows available for possible use */ public void setAvailableFlows(@Nonnull @NonnullElements final Collection<AuthenticationFlowDescriptor> flows) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(flows, "Flow collection cannot be null"); availableFlows = new ArrayList<>(Collections2.filter(flows, Predicates.notNull())); }