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:org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery.java
/** * Check if this {@link DDiagramElement} is indirectly collapsed. * // w w w . j a va2 s . c o m * @return true if the given element is indirectly filtered. */ public boolean isOnlyIndirectlyCollapsed() { return Iterables.any(element.getGraphicalFilters(), Predicates.instanceOf(IndirectlyCollapseFilter.class)); }
From source file:org.immutables.sequence.Sequence.java
/** * Returns {@code true} if any element in this fluent iterable satisfies the predicate. * @param predicate the predicate// ww w . j a v a 2 s . c o m * @return true, if successful */ public final boolean anyMatch(Predicate<? super E> predicate) { return Iterables.any(iterable, predicate::test); }
From source file:org.opentestsystem.authoring.testauth.publish.SharedPublisherHelper.java
private List<TestComputationRule> buildTestComputationRulesForLeafNodeRules( final List<ScoringRule> scoringRuleList, final List<BlueprintElement> blueprintElementList) { final List<TestComputationRule> testComputationRuleList = Lists.newArrayList(); if (Iterables.any(scoringRuleList, LEAF_NODE_TYPE_FILTER)) { // winnow blueprintElement list down to parentedChildren only Iterables.removeIf(blueprintElementList, PARENT_KEY_FILTER); // build multimap of bpe keyed by parent key final Multimap<String, BlueprintElement> blueprintElementParentKeyMultimap = Multimaps .index(blueprintElementList, BP_PARENT_KEY_TRANSFORMER); // filter bpe objects that are parents from parentedChildren Iterables.removeIf(blueprintElementList, NON_LEAF_NODE_FILTER.getInstance(blueprintElementParentKeyMultimap.keySet())); // construct each leaf node into a separate scoring rule final List<ScoringRule> leafNodeScoringRules = Lists .newArrayList(Iterables.filter(scoringRuleList, LEAF_NODE_TYPE_FILTER)); for (final ScoringRule scoringRule : leafNodeScoringRules) { final int i = 1; // transform every leaf node bp element into a scoring rule mimicking this scoringRule testComputationRuleList.addAll(Lists.transform(blueprintElementList, LEAF_NODE_LEVEL_SCORING_RULE_TRANSFORMER.getInstance(scoringRule, i))); }/*from w w w. jav a 2 s.co m*/ } return testComputationRuleList; }
From source file:org.eclipse.elk.alg.graphviz.layouter.LayoutDotExporter.java
/** * {@inheritDoc}//w ww . j a v a 2 s .co m */ @Override protected void setEdgeLabels(final KEdge kedge, final List<Attribute> attributes, final boolean isVertical) { super.setEdgeLabels(kedge, attributes, isVertical); // set label distance and angle if (Iterables.any(kedge.getLabels(), (KLabel label) -> { KShapeLayout labelLayout = label.getData(KShapeLayout.class); EdgeLabelPlacement elp = labelLayout.getProperty(CoreOptions.EDGE_LABELS_PLACEMENT); return elp == EdgeLabelPlacement.HEAD || elp == EdgeLabelPlacement.TAIL; })) { KEdgeLayout edgeLayout = kedge.getData(KEdgeLayout.class); float distance = edgeLayout.getProperty(GraphvizMetaDataProvider.LABEL_DISTANCE); if (distance >= 0.0f) { attributes.add(createAttribute(Attributes.LABELDISTANCE, distance)); } float angle = edgeLayout.getProperty(GraphvizMetaDataProvider.LABEL_ANGLE); attributes.add(createAttribute(Attributes.LABELANGLE, angle)); } }
From source file:com.eucalyptus.tags.TagManager.java
private static boolean isReserved(final String text) { return !Contexts.lookup().isPrivileged() && Iterables.any(reservedPrefixes, prefix(text)); }
From source file:dagger.internal.codegen.ComponentWriter.java
/** {@code true} if all of the graph's required dependencies can be automatically constructed. */ private boolean canInstantiateAllRequirements() { return !Iterables.any(graph.componentRequirements(), dependency -> dependency.requiresAPassedInstance(elements, types)); }
From source file:gov.nih.nci.firebird.web.action.investigator.profile.AbstractProfileAction.java
private boolean doesFileAlreadyExist(final Struts2UploadedFileInfo dataFile) { return Iterables.any(getProfile().getUploadedFiles(), new Predicate<FirebirdFile>() { @Override// ww w . ja v a 2s . c o m public boolean apply(FirebirdFile firebirdFile) { return dataFile.getDataFileName().equalsIgnoreCase((firebirdFile).getName()); } }); }
From source file:edu.harvard.med.screensaver.model.meta.RelationshipPath.java
public boolean hasRestrictions() { return Iterables.any(_restrictions, Predicates.notNull()); }
From source file:com.b2international.snowowl.snomed.api.impl.SnomedRf2ImportService.java
private boolean isImportAlreadyRunning() { return Iterables.any(configurationMapping.values(), new Predicate<ISnomedImportConfiguration>() { @Override/*ww w.j av a2s . co m*/ public boolean apply(final ISnomedImportConfiguration configuration) { return ImportStatus.RUNNING.equals(configuration.getStatus()); } }); }
From source file:org.apache.brooklyn.rest.filter.CsrfTokenFilter.java
@Override public void filter(ContainerRequestContext requestContext) throws IOException { // if header supplied, check it is valid String requiredWhenS = request.getHeader(CSRF_TOKEN_REQUIRED_HEADER); if (Strings.isNonBlank(requiredWhenS) && getRequiredForRequests(requiredWhenS, null) == null) { fail(requestContext,/* w ww . j a va 2s . c o m*/ ApiError.builder().errorCode(Response.Status.BAD_REQUEST) .message(HEADER_OF_COOKIE(CSRF_TOKEN_REQUIRED_HEADER) + " header if supplied must be one of " + Arrays.asList(CsrfTokenRequiredForRequests.values())) .build()); return; } if (!request.isRequestedSessionIdValid()) { // no session; just return return; } @SuppressWarnings("unchecked") List<String> suppliedTokensDefault = EnumerationUtils.toList(request.getHeaders(CSRF_TOKEN_VALUE_HEADER)); @SuppressWarnings("unchecked") List<String> suppliedTokensAngular = EnumerationUtils .toList(request.getHeaders(CSRF_TOKEN_VALUE_HEADER_ANGULAR_NAME)); List<String> suppliedTokens = Lists.newArrayList(suppliedTokensDefault); suppliedTokens.addAll(suppliedTokensAngular); Object requiredToken = request.getSession().getAttribute(CSRF_TOKEN_VALUE_ATTR); CsrfTokenRequiredForRequests whenRequired = (CsrfTokenRequiredForRequests) request.getSession() .getAttribute(CSRF_TOKEN_REQUIRED_ATTR); boolean isRequired; if (whenRequired == null) { if (suppliedTokens.isEmpty()) { log.warn( "No CSRF token expected or supplied but a cookie-session is active: client should be updated" + " (in future CSRF tokens or instructions may be required for session-based clients)" + " - " + Entitlements.getEntitlementContext()); whenRequired = CsrfTokenRequiredForRequests.NONE; } else { // default whenRequired = DEFAULT_REQUIRED_FOR_REQUESTS; } // remember it to suppress warnings subsequently request.getSession().setAttribute(CSRF_TOKEN_REQUIRED_ATTR, whenRequired); } switch (whenRequired) { case NONE: isRequired = false; break; case WRITE: isRequired = !org.eclipse.jetty.http.HttpMethod.GET.toString().equals(requestContext.getMethod()); break; case ALL: isRequired = true; break; default: log.warn("Unexpected " + CSRF_TOKEN_REQUIRED_ATTR + " value " + whenRequired); isRequired = true; } if (Iterables.any(suppliedTokens, Predicates.equalTo(requiredToken))) { // matching token supplied, or not being used return; } if (!isRequired) { // csrf not required, but it doesn't match if (requiredToken != null) { log.trace( "CSRF optional token mismatch: client did not send valid token, but it isn't required so proceeding"); } return; } if (suppliedTokens.isEmpty()) { fail(requestContext, ApiError.builder().errorCode(Response.Status.UNAUTHORIZED) .message(HEADER_OF_COOKIE(CSRF_TOKEN_VALUE_COOKIE) + " header is required, containing token previously returned from server in cookie") .build()); } else { fail(requestContext, ApiError.builder().errorCode(Response.Status.UNAUTHORIZED).message( HEADER_OF_COOKIE(CSRF_TOKEN_VALUE_COOKIE) + " header did not match expected CSRF token") .build()); } }