Java Code Examples for java.util.Collection#contains()

The following examples show how to use java.util.Collection#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeTypeRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isValidOrConstraint(ITypeBinding type,
									Collection<ConstraintVariable> relevantVars,
									CompositeOrTypeConstraint cotc){
	ITypeConstraint[] components= cotc.getConstraints();
	for (int i= 0; i < components.length; i++) {
		if (components[i] instanceof SimpleTypeConstraint) {
			SimpleTypeConstraint sc= (SimpleTypeConstraint) components[i];
			if (relevantVars.contains(sc.getLeft())) { // upper bound
				if (isSubTypeOf(type, findType(sc.getRight())))
					return true;
			} else if (relevantVars.contains(sc.getRight())) { // lower bound
				if (isSubTypeOf(findType(sc.getLeft()), type))
					return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: EntityRightsFilter.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void filterFields(EntityBody entityBody, Collection<GrantedAuthority> auths, String prefix,
        String entityType) {

    if (!auths.contains(Right.FULL_ACCESS)) {

        List<String> toRemove = new LinkedList<String>();

        for (Iterator<Map.Entry<String, Object>> it = entityBody.entrySet().iterator(); it.hasNext();) {
            String fieldName = it.next().getKey();

            Set<Right> neededRights = rightAccessValidator.getNeededRights(prefix + fieldName, entityType);

            if (!neededRights.isEmpty() && !rightAccessValidator.intersection(auths, neededRights)) {
                it.remove();
            }
        }
    }
}
 
Example 3
Source File: NestedScrollingWidgetDetector.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private Element findOuterScrollingWidget(Node node, boolean vertical) {
    Collection<String> applicableElements = getApplicableElements();
    while (node != null) {
        if (node instanceof Element) {
            Element element = (Element) node;
            String tagName = element.getTagName();
            if (applicableElements.contains(tagName)
                    && vertical == isVerticalScroll(element)) {
                return element;
            }
        }

        node = node.getParentNode();
    }

    return null;
}
 
Example 4
Source File: Utils.java    From AsteroidOSSync with GNU General Public License v3.0 6 votes vote down vote up
public static boolean haveMatchingIds(List<UUID> advertisedIds, Collection<UUID> lookedForIds)
{
	if(lookedForIds != null && !lookedForIds.isEmpty())
	{
		boolean match = false;

		for(int i = 0; i < advertisedIds.size(); i++)
		{
			if(lookedForIds.contains(advertisedIds.get(i)))
			{
				match = true;
				break;
			}
		}

		if(!match)
			return false;
	}

	return true;
}
 
Example 5
Source File: Schema.java    From iceberg with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a projection schema for a subset of columns, selected by name.
 * <p>
 * Names that identify nested fields will select part or all of the field's top-level column.
 *
 * @param names a List of String names for selected columns
 * @return a projection schema from this schema, by name
 */
public Schema select(Collection<String> names) {
  if (names.contains(ALL_COLUMNS)) {
    return this;
  }

  Set<Integer> selected = Sets.newHashSet();
  for (String name : names) {
    Integer id = lazyNameToId().get(name);
    if (id != null) {
      selected.add(id);
    }
  }

  return TypeUtil.select(this, selected);
}
 
Example 6
Source File: AbstractLookupBaseHid.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Items are the same as results.
 */
public void testItemsAndIntances () {
    addInstances (INSTANCES);
    
    Lookup.Result<Object> r = lookup.lookupResult(Object.class);
    Collection<? extends Lookup.Item<?>> items = r.allItems();
    Collection<?> insts = r.allInstances();
    
    if (items.size () != insts.size ()) {
        fail ("Different size of sets");
    }

    for (Lookup.Item<?> item : items) {
        if (!insts.contains (item.getInstance ())) {
            fail ("Intance " + item.getInstance () + " is missing in " + insts);
        }
    }
}
 
Example 7
Source File: RelatedConceptsITCase.java    From find with MIT License 6 votes vote down vote up
private String clickFirstNewConcept(final Collection<String> existingConcepts,
                                    final Iterable<WebElement> relatedConcepts) {
    for(final WebElement concept : relatedConcepts) {
        final String conceptText = concept.getText();
        if(!existingConcepts.contains(conceptText)) {
            LOGGER.info("Clicking concept " + conceptText);
            concept.click();

            existingConcepts.add(conceptText.toLowerCase());

            return conceptText;
        }
    }

    throw new NoSuchElementException("no new related concepts");
}
 
Example 8
Source File: DOMContentUtils.java    From anthelion with Apache License 2.0 6 votes vote down vote up
public void setConf(Configuration conf) {
  // forceTags is used to override configurable tag ignoring, later on
  Collection<String> forceTags = new ArrayList<String>(1);

  this.conf = conf;
  linkParams.clear();
  linkParams.put("a", new LinkParams("a", "href", 1));
  linkParams.put("area", new LinkParams("area", "href", 0));
  if (conf.getBoolean("parser.html.form.use_action", true)) {
    linkParams.put("form", new LinkParams("form", "action", 1));
    if (conf.get("parser.html.form.use_action") != null)
      forceTags.add("form");
  }
  linkParams.put("frame", new LinkParams("frame", "src", 0));
  linkParams.put("iframe", new LinkParams("iframe", "src", 0));
  linkParams.put("script", new LinkParams("script", "src", 0));
  linkParams.put("link", new LinkParams("link", "href", 0));
  linkParams.put("img", new LinkParams("img", "src", 0));

  // remove unwanted link tags from the linkParams map
  String[] ignoreTags = conf.getStrings("parser.html.outlinks.ignore_tags");
  for ( int i = 0 ; ignoreTags != null && i < ignoreTags.length ; i++ ) {
    if ( ! forceTags.contains(ignoreTags[i]) )
      linkParams.remove(ignoreTags[i]);
  }
}
 
Example 9
Source File: ObjHashSet.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public boolean retainAll(Collection<?> c) {
  boolean anyChanged = false;
  Iterator<T> it = iterator();
  while (it.hasNext()) {
    T v = it.next();
    if (!c.contains(v)) {
      anyChanged = true;
      it.remove();
    }
  }
  return anyChanged;
}
 
Example 10
Source File: ReferenceGraph.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private ReferenceGraph getSubgraph(Collection<TypeNode> vertices) {
  ReferenceGraph subgraph = new ReferenceGraph();
  for (TypeNode type : vertices) {
    for (Edge e : edges.get(type)) {
      if (vertices.contains(e.getTarget())) {
        subgraph.addEdge(e);
      }
    }
  }
  return subgraph;
}
 
Example 11
Source File: ChanManager.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void invalidateChansOrder() {
	ArrayList<String> orderedChanNames = Preferences.getChansOrder();
	if (orderedChanNames != null) {
		Collection<String> oldAvailableChanNames = availableChanNames;
		availableChanNames = new LinkedHashSet<>();
		for (String chanName : orderedChanNames) {
			if (oldAvailableChanNames.contains(chanName)) {
				availableChanNames.add(chanName);
			}
		}
		availableChanNames.addAll(oldAvailableChanNames);
	}
}
 
Example 12
Source File: DataRequestSessionImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void validateBindings( List<IBinding> bindings,
		Collection calculatedMeasures ) throws AdapterException
{
	// Not support aggregation filter reference calculated measures.
	try
	{
		for ( IBinding b : bindings )
		{
			if ( b.getAggrFunction( ) == null || b.getFilter( ) == null )
				continue;
			
			List referencedMeasures = ExpressionCompilerUtil.extractColumnExpression( b.getFilter( ),
					ExpressionUtil.MEASURE_INDICATOR );
			for ( Object r : referencedMeasures )
			{
				if ( calculatedMeasures.contains( r.toString( ) ) )
				{
					throw new AdapterException( AdapterResourceHandle.getInstance( )
							.getMessage( ResourceConstants.CUBE_AGGRFILTER_REFER_CALCULATEDMEASURE,
									new Object[]{
											b.getBindingName( ),
											r.toString( )
									} ) );
				}
			}
		}
	}
	catch ( DataException ex )
	{
		throw new AdapterException( ex.getMessage( ), ex );
	}
}
 
Example 13
Source File: QueryInterceptor.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void intercept(List<OLAPContext> contexts, Collection<String> blackList) {
    if (blackList.isEmpty()) {
        return;
    }

    Collection<String> queryCols = getQueryIdentifiers(contexts);
    for (String id : blackList) {
        if (queryCols.contains(id.toUpperCase(Locale.ROOT))) {
            throw new AccessDeniedException(getIdentifierType() + ":" + id);
        }
    }
}
 
Example 14
Source File: InterpreterInfo.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Add additions that are not already in col
 */
private static void addUnique(Collection<String> col, Collection<String> additions) {
    for (String string : additions) {
        if (!col.contains(string)) {
            col.add(string);
        }
    }
}
 
Example 15
Source File: AbstractMultimap.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean containsValue(@Nullable Object value) {
  for (Collection<V> collection : asMap().values()) {
    if (collection.contains(value)) {
      return true;
    }
  }

  return false;
}
 
Example 16
Source File: AbstractLinkedList.java    From Penetration_Testing_POC with Apache License 2.0 5 votes vote down vote up
public boolean removeAll(Collection coll) {
    boolean modified = false;
    Iterator it = iterator();
    while (it.hasNext()) {
        if (coll.contains(it.next())) {
            it.remove();
            modified = true;
        }
    }
    return modified;
}
 
Example 17
Source File: Permissions.java    From elepy with Apache License 2.0 5 votes vote down vote up
public boolean hasPermissions(Collection<String> permissionsToCheck) {
    if (permissionsToCheck.contains(DISABLED)) {
        return false;
    }
    if (grantedPermissions.contains(SUPER_USER) || permissionsToCheck.isEmpty()) {
        return true;
    }

    return permissionsToCheck.stream().allMatch(this::hasPermission);
}
 
Example 18
Source File: BlackDuckDistributionFilter.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
private boolean doProjectsFromNotificationMatchConfiguredProjects(AlertNotificationModel notification, Collection<String> configuredProjects, @Nullable String nullablePattern) {
    Collection<String> notificationProjectNames = blackDuckProjectNameExtractor.getProjectNames(getCache(), notification);
    for (String notificationProjectName : notificationProjectNames) {
        if (configuredProjects.contains(notificationProjectName) || (null != nullablePattern && notificationProjectName.matches(nullablePattern))) {
            return true;
        }
    }
    return false;
}
 
Example 19
Source File: Test.java    From spring-boot with Apache License 2.0 4 votes vote down vote up
public Object copyBeanProperties(final Object source, final Collection<String> includes) {

        final Collection<String> excludes = new ArrayList<String>();
        final PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(source.getClass());

        Object entityBeanVO = BeanUtils.instantiate(source.getClass());

        for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) {

            String propName = propertyDescriptor.getName();
            if (!includes.contains(propName)) {
                excludes.add(propName);
            }


        }

        BeanUtils.copyProperties(source, entityBeanVO, excludes.toArray(new String[excludes.size()]));

        return entityBeanVO;
    }
 
Example 20
Source File: CallActivityCanonicalEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) {
	return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement());
}