下面列出了java.util.Collection#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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();
}
}
}
}
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;
}
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;
}
/**
* 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);
}
/** 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);
}
}
}
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]);
}
}
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");
}
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;
}
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;
}
@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;
}
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);
}
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;
}
@Override
public boolean containsValue(@Nullable Object value) {
for (Collection<V> collection : asMap().values()) {
if (collection.contains(value)) {
return true;
}
}
return false;
}
/**
* 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);
}
}
}
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);
}
}
}
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 );
}
}
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);
}
}
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;
}
/**
* @generated
*/
protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) {
return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement());
}
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;
}