List of usage examples for com.google.common.collect Iterables any
public static <T> boolean any(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:com.facebook.buck.apple.AbstractAppleNativeTargetBuildRuleDescriptions.java
private static SymlinkTree createSymlinkTree(BuildRuleParams params, SourcePathResolver pathResolver, ImmutableSortedMap<SourcePath, String> perFileFlags, boolean useBuckHeaderMaps) { // Note that the set of headersToCopy may be empty. If so, the returned rule will be a no-op. // TODO(mbolin): Make headersToCopy an ImmutableSortedMap once we clean up the iOS codebase and // can guarantee that the keys are unique. Map<Path, SourcePath> headersToCopy; if (useBuckHeaderMaps) { // No need to copy headers because header maps are used. headersToCopy = ImmutableSortedMap.of(); } else {/*from w ww. ja va 2s . c o m*/ // This is a heuristic to get the right header path prefix. Note that ProjectGenerator uses a // slightly different heuristic, which is buildTarget.getShortNameOnly(), though that is only // a fallback when an apple_library() does not specify a header_path_prefix when // use_buck_header_maps is True. Path headerPathPrefix = params.getBuildTarget().getBasePath().getFileName(); headersToCopy = Maps.newHashMap(); Splitter spaceSplitter = Splitter.on(' ').trimResults().omitEmptyStrings(); Predicate<String> isPublicHeaderFlag = Predicates.equalTo("public"); for (Map.Entry<SourcePath, String> entry : perFileFlags.entrySet()) { String flags = entry.getValue(); if (Iterables.any(spaceSplitter.split(flags), isPublicHeaderFlag)) { SourcePath sourcePath = entry.getKey(); Path sourcePathName = pathResolver.getPath(sourcePath).getFileName(); headersToCopy.put(headerPathPrefix.resolve(sourcePathName), sourcePath); } } } BuildRuleParams headerParams = params.copyWithDeps(/* declaredDeps */ ImmutableSortedSet.<BuildRule>of(), params.getExtraDeps()); Path root = getPathToHeaders(params.getBuildTarget()); return new SymlinkTree(headerParams, pathResolver, root, ImmutableMap.copyOf(headersToCopy)); }
From source file:org.opentestsystem.authoring.testauth.publish.RegistrationPublisherHelper.java
@Override public TestSpecification<Registration> createTestSpec(final Assessment assessment, final DateTime publishDate, final String version, final Purpose purpose, final TestSpecification<? extends PurposeBaseContent> seedingTestSpec) {// ignore/disregard seedingTestSpec as not really usable for Registration final long start = System.currentTimeMillis(); final TestSpecification<Registration> testSpec = doGeneralTestSpecificationSetup(assessment, publishDate, version, purpose, Registration.class); final Registration specContent = new Registration(); final String assessmentId = assessment.getId(); final List<Segment> segmentList = retrieveSegmentList(assessmentId); final List<AffinityGroup> affinityGroupList = getActiveAffinityGroups(assessmentId); final List<Item> itemList = retrieveItemsForAssessment(assessmentId); final long dataRetrieval = System.currentTimeMillis(); final ItemPool itemPool = setupItemPoolData(assessment, itemList, segmentList, affinityGroupList, version); final Map<String, TestItem> testItemMap = buildTestItemMap(itemPool.getTestItemList()); final List<List<PoolProperty>> poolPropertyLists = Lists.newArrayList(); final long itemPoolCreation = System.currentTimeMillis(); // SEGMENT/*from w ww . j a v a2 s. c o m*/ final List<RegistrationSegment> registrationSegmentList = Lists.newArrayList(); for (final Segment segment : segmentList) { final ItemSelectionAlgorithmType segmentType = segment.getItemSelectionAlgorithm() .getItemSelectionAlgorithmType(); final List<Item> filteredItemList = Lists .newArrayList(Iterables.concat(retrieveScopedItems(assessment.getId(), itemList, segment.getId(), segmentType.equals(ItemSelectionAlgorithmType.FIXEDFORM)).values())); final RegistrationSegment registrationSegment = new RegistrationSegment(segment.getPosition(), segmentType.name(), new Identifier(segment.getId(), segment.getLabel(), segment.getLabel(), DEFAULT_VERSION), null, null, segment.getMinOpItems() + segment.getMinFtItems(), segment.getMaxOpItems() + segment.getMaxFtItems(), buildPoolPropertyListFromItemList(testItemMap, filteredItemList)); registrationSegmentList.add(registrationSegment); poolPropertyLists.add(registrationSegment.getPoolPropertyList()); } specContent.setRegistrationSegmentList(registrationSegmentList); final long segmentCreation = System.currentTimeMillis(); // FORM long formCreation = segmentCreation; if (Iterables.any(segmentList, FIXEDFORM_SEGMENT_FILTER)) { final List<RegistrationForm> formList = Lists.newArrayList(); final SearchResponse<Form> formSearchResponse = this.formService .searchForms(TestAuthUtil.searchParamsByAssessmentIdLarge(assessment.getId())); for (final Form form : formSearchResponse.getSearchResults()) { final List<Item> filteredItemList = Lists.newArrayList( Iterables.concat(retrieveScopedItems(assessment.getId(), itemList, null, true).values())); final RegistrationForm registrationForm = doGeneralFormSetup(RegistrationForm.class, form, filteredItemList, testItemMap, assessment.getVersion()); formList.add(registrationForm); } specContent.setRegistrationFormList(formList); formCreation = System.currentTimeMillis(); } // top-level pool property specContent .setPoolPropertyList(sumPoolPropertyLists(Lists.newArrayList(Iterables.concat(poolPropertyLists)))); final long poolCreation = System.currentTimeMillis(); testSpec.setContent(specContent); if (LOGGER.isDebugEnabled()) { LOGGER.debug("data retrieval: " + (dataRetrieval - start) + "ms\n" + "item pool: " + (itemPoolCreation - dataRetrieval) + "ms\n" + "registration segment: " + (segmentCreation - itemPoolCreation) + "ms\n" + "form: " + (formCreation - segmentCreation) + "ms\n" + "test poolproperty: " + (poolCreation - formCreation) + "ms\n" + "total time: " + (System.currentTimeMillis() - start) + "ms"); } return testSpec; }
From source file:org.apache.aurora.scheduler.filter.SchedulingFilterImpl.java
private boolean isDedicated(IHostAttributes attributes) { return Iterables.any(attributes.getAttributes(), new ConstraintMatcher.NameFilter(DEDICATED_ATTRIBUTE)); }
From source file:com.eucalyptus.cloudformation.resources.standard.TagHelper.java
public static void checkReservedAutoScalingTemplateTags(List<AutoScalingTag> tags) throws ValidationErrorException { if (tags == null) return;/* w ww.j a v a2 s .com*/ List<String> tagNames = Lists.newArrayList(); for (AutoScalingTag tag : tags) { if (Iterables.any(reservedPrefixes, Strings.isPrefixOf(tag.getKey()))) { throw new ValidationErrorException( "Tag " + tag.getKey() + " uses a reserved prefix " + reservedPrefixes); } } }
From source file:com.censoredsoftware.infractions.bukkit.origin.Origin.java
/** * Set of Dossiers with data from this Origin. * * @return Dossiers.//from w w w.j a va 2s . co m */ public Set<Dossier> getContributedDossiers() { final Origin origin = this; return Sets.filter(Infractions.allDossiers(), new Predicate<Dossier>() { @Override public boolean apply(Dossier dossier) { return Iterables.any(dossier.getInfractions(), new Predicate<Infraction>() { @Override public boolean apply(Infraction infraction) { return origin.equals(infraction.getOrigin()) || Iterables.any(infraction.getEvidence(), new Predicate<Evidence>() { @Override public boolean apply(Evidence evidence) { return origin.equals(evidence.getOrigin()); } }); } }); } }); }
From source file:pl.nalazek.githubsearch.data.GitHubRepositoryAPI.java
private boolean anyIsNull(Query[] queries) { return Iterables.any(Arrays.asList(queries), isNullQuery); }
From source file:com.eucalyptus.cluster.ResourceState.java
public boolean hasUnorderedTokens() { return Iterables.any(this.pendingTokens, new Predicate<ResourceToken>() { @Override//www.ja v a 2 s . c om public boolean apply(ResourceToken arg0) { return arg0.isUnorderedType(); } }); }
From source file:org.jclouds.compute.domain.internal.TemplateBuilderImpl.java
static Predicate<Hardware> supportsImagesPredicate(final Iterable<? extends Image> images) { return new Predicate<Hardware>() { @Override//from w ww. j a v a2 s . co m public boolean apply(final Hardware hardware) { return Iterables.any(images, new Predicate<Image>() { @Override public boolean apply(Image input) { return hardware.supportsImage().apply(input); } @Override public String toString() { return "hardware(" + hardware + ").supportsImage()"; } }); } }; }
From source file:com.eucalyptus.util.NetworkUtil.java
public static boolean testLocal(final InetAddress addr) { Exceptions.ifNullArgument(addr);// w w w . j a va2 s . c o m try { Boolean result = addr.isAnyLocalAddress(); result |= Iterables.any(Collections.list(NetworkInterface.getNetworkInterfaces()), new Predicate<NetworkInterface>() { @Override public boolean apply(NetworkInterface arg0) { return Iterables.any(arg0.getInterfaceAddresses(), new Predicate<InterfaceAddress>() { @Override public boolean apply(InterfaceAddress arg0) { return arg0.getAddress().equals(addr); } }); } }); return result; } catch (Exception e) { return Exceptions.eat(e.getMessage(), e); } }
From source file:org.apache.kylin.metadata.project.ProjectInstance.java
public boolean containsRealization(final RealizationType type, final String realization) { return Iterables.any(this.realizationEntries, new Predicate<RealizationEntry>() { @Override/* ww w .ja v a 2 s . c o m*/ public boolean apply(RealizationEntry input) { return input.getType() == type && input.getRealization().equalsIgnoreCase(realization); } }); }