當前位置: 首頁>>代碼示例>>Java>>正文


Java Collection.containsAll方法代碼示例

本文整理匯總了Java中java.util.Collection.containsAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Collection.containsAll方法的具體用法?Java Collection.containsAll怎麽用?Java Collection.containsAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Collection的用法示例。


在下文中一共展示了Collection.containsAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mutatesTo

import java.util.Collection; //導入方法依賴的package包/類
protected boolean mutatesTo(Object o1, Object o2) {
    if (BeansUtils.declaredEquals(o1.getClass())) {
        return o1.equals(o2);
    }
    if (o1 instanceof Collection<?>) {
        Collection<?> c1 = (Collection<?>) o1;
        Collection<?> c2 = (Collection<?>) o2;
        return c1.size() == c2.size() && c1.containsAll(c2);
    }
    if (o1 instanceof Map<?, ?>) {
        Map<?, ?> m1 = (Map<?, ?>) o1;
        Map<?, ?> m2 = (Map<?, ?>) o2;
        return m1.size() == m2.size()
                && m1.entrySet().containsAll(m2.entrySet());
    }
    return super.mutatesTo(o1, o2);
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:18,代碼來源:UtilCollectionsPersistenceDelegate.java

示例2: alwaysWriteConflicting

import java.util.Collection; //導入方法依賴的package包/類
/**
 * Returns true if this Statement will always conflict with other WRITE queries
 * @param stmt
 * @param type
 * @param tables
 * @param cols
 * @return
 */
private boolean alwaysWriteConflicting(Statement stmt,
                                       QueryType type,
                                       Collection<Table> tables,
                                       Collection<Column> cols) {
    if (type == QueryType.UPDATE || type == QueryType.DELETE) {
        
        // Any UPDATE or DELETE statement that does not use a primary key in its WHERE 
        // clause should be marked as always conflicting.
        // Note that pkeys will be null here if there is no primary key for the table
        Collection<Column> pkeys = this.pkeysCache.get(CollectionUtil.first(tables));
        if (pkeys == null || cols.containsAll(pkeys) == false) {
            return (true);
        }
        // Or any UPDATE or DELETE with a range predicate in its WHERE clause always conflicts
        else if (PlanNodeUtil.isRangeQuery(PlanNodeUtil.getRootPlanNodeForStatement(stmt, true))) {
            return (true);
        }
    }
    return (false);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:29,代碼來源:ConflictSetCalculator.java

示例3: addTables

import java.util.Collection; //導入方法依賴的package包/類
/**
 * Creates the list of Statement catalog keys that we want to let
 * through our filter
 * 
 * @param tables
 * @throws Exception
 */
protected void addTables(Collection<Table> tables) throws Exception {
    // Iterate through all of the procedures/queries and figure out
    // which
    // ones we'll actually want to look at
    Database catalog_db = (Database) CollectionUtil.first(tables).getParent();
    for (Procedure catalog_proc : catalog_db.getProcedures()) {
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            Collection<Table> stmt_tables = CatalogUtil.getReferencedTables(catalog_stmt);
            if (tables.containsAll(stmt_tables)) {
                this.stmt_cache.add(CatalogKey.createKey(catalog_stmt));
            }
        } // FOR
    } // FOR
    return;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:23,代碼來源:AbstractPartitioner.java

示例4: checkPermitted

import java.util.Collection; //導入方法依賴的package包/類
@Override
protected boolean checkPermitted(Authentication authentication, Collection<? extends Permission> permissions,
		boolean all) {
	if (authentication != null && authentication.isRoot()) {
		return true;
	}
	if (authentication != null && permissions != null && !permissions.isEmpty()) {
		Collection<Permission> granted = authentication.getPermissions();
		if (granted != null && !granted.isEmpty()) {
			if (all) {
				return granted.containsAll(permissions);
			} else {
				for (Permission p : permissions) {
					if (granted.contains(p)) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:23,代碼來源:DefaultAuthorizer.java

示例5: findDangers

import java.util.Collection; //導入方法依賴的package包/類
public Set<DangerStatement> findDangers(Collection<DangerStatement> allowedDangers) {
    Set<DangerStatement> allDangers = EnumSet.allOf(DangerStatement.class);
    if (allowedDangers.containsAll(allDangers)) {
        return Collections.emptySet();
    }

    Set<DangerStatement> dangerTypes = EnumSet.noneOf(DangerStatement.class);
    for (PgDiffStatement st : statements) {
        for (DangerStatement d : allDangers) {
            if (!allowedDangers.contains(d) && st.isDangerStatement(d)) {
                dangerTypes.add(d);
            }
        }
    }
    return dangerTypes;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:17,代碼來源:PgDiffScript.java

示例6: setUnits

import java.util.Collection; //導入方法依賴的package包/類
@Override
public final void setUnits(final List<UpdateUnit> unused) {
    getLocalDownloadSupport ().removeInstalledUnit ();
    Collection<UpdateUnit> units = getLocalDownloadSupport().getUpdateUnits();
    //do not compute if not necessary
    if (cachedUnits == null || !units.containsAll (cachedUnits) || !cachedUnits.containsAll (units)) {
        setData(makeCategories (new LinkedList<UpdateUnit> (units)));
        cachedUnits = new ArrayList<UpdateUnit>(units);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:LocallyDownloadedTableModel.java

示例7: twoDevicesOneGettingState

import java.util.Collection; //導入方法依賴的package包/類
@Test
public void twoDevicesOneGettingState() throws Throwable {

	final List<Throwable> exceptions = new ArrayList<>(1);

	// Start writing in thread.
	configure(device, 10);
	runDeviceInThread(device, exceptions); // Don't use device returned.

	// In this test thread, we simply keep asking for the state.
	// We get an instance to the device separately to test two
	// device connections (although MockService will not do this)
	final Collection<DeviceState> states = new HashSet<DeviceState>();
	try {
		IMalcolmDevice zebra = (IMalcolmDevice) service.getRunnableDevice("zebra");
		zebra.addMalcolmListener(new IMalcolmListener<MalcolmEventBean>() {
			@Override
			public void eventPerformed(MalcolmEvent<MalcolmEventBean> e) {
				states.add(e.getBean().getDeviceState());
			}
		});

		for (int i = 0; i < 10; i++) {
			System.out.println("Device state is "+zebra.getDeviceState());
			if (zebra.getDeviceState() == DeviceState.READY) {
				throw new Exception("The device should not be READY! It was "+zebra.getDeviceState());
			}
			Thread.sleep(1000);
		}
	} finally {
	}

	if (!states.containsAll(Arrays.asList(new DeviceState[]{DeviceState.ARMED, DeviceState.RUNNING}))){
		throw new Exception("Not all expected states encountered during run! States found were "+states);
	}

	if (exceptions.size()>0) throw exceptions.get(0);
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:39,代碼來源:AbstractMultipleClientMalcolmTest.java

示例8: checkFilesFound

import java.util.Collection; //導入方法依賴的package包/類
public static void checkFilesFound(Collection<String> found, Path... expected) {

        Collection<String> expectedStrs = new HashSet<String>();
        for (Path p : expected)
            expectedStrs.add(p.toString());

        if (!expectedStrs.containsAll(found))
            throw new AssertionError("Expected (" + expectedStrs + ") does not " +
                                     "contain all actual (" + found + ")");

        if (!found.containsAll(expectedStrs))
            throw new AssertionError("Actual (" + found + ") does not " +
                                     "contain all expected (" + expectedStrs + ")");
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:OptionTestUtil.java

示例9: twoDevicesOneGettingStateWithPausing

import java.util.Collection; //導入方法依賴的package包/類
@Test
public void twoDevicesOneGettingStateWithPausing() throws Throwable {

	final List<Throwable> exceptions = new ArrayList<>(1);

	final Collection<DeviceState> states = new HashSet<DeviceState>();
	try {
		// Add listener
		IMalcolmDevice zebra = (IMalcolmDevice) service.getRunnableDevice("zebra");
		zebra.addMalcolmListener(new IMalcolmListener<MalcolmEventBean>() {
			@Override
			public void eventPerformed(MalcolmEvent<MalcolmEventBean> e) {
				states.add(e.getBean().getDeviceState());
			}
		});

		// Start writing in thread using different device reference.
		pause1000ResumeLoop(device, 5, 2, 2000, false, false, true); // Run scan in thread, run pause in thread, use separate device connections

		// In this test thread, we simply keep asking for the state.
		// We get an instance to the device separately to test two
		// device connections (although MockService will not do this)
		for (int i = 0; i < 10; i++) {
			System.out.println("Device state is "+zebra.getDeviceState());
			if (zebra.getDeviceState() == DeviceState.READY) {
				throw new Exception("The device should not be READY!");
			}
			Thread.sleep(1000);
		}
	} finally {
	}

	if (!states.containsAll(Arrays.asList(new DeviceState[]{DeviceState.ARMED, DeviceState.RUNNING, DeviceState.PAUSED, DeviceState.SEEKING}))){
		throw new Exception("Not all expected states encountered during run! States found were "+states);
	}

	if (exceptions.size()>0) throw exceptions.get(0);
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:39,代碼來源:AbstractMultipleClientMalcolmTest.java

示例10: updateServers

import java.util.Collection; //導入方法依賴的package包/類
/**
 * Checks for updates in the list of relevant servers.
 * Rebuilds the load balancer if server list changed.
 * @param newServers The newly received list from the registry.
 */
void updateServers(Collection<Server> newServers) {
	Set<Server> oldServers = clients.keySet();
	//don't do anything if nothing changed
	if (oldServers.size() == newServers.size() && newServers.containsAll(oldServers)) {
		return;
	}
	updateClients(newServers);
}
 
開發者ID:DescartesResearch,項目名稱:Pet-Supply-Store,代碼行數:14,代碼來源:EndpointClientCollection.java

示例11: annotate

import java.util.Collection; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof CallStatementElement) {
    CallStatementElement statement = (CallStatementElement) psiElement;

    Collection<String> givenParameters = ParamUtils.getGivenParameters(statement);

    // TODO(thso): Detect data="" in more robust way.
    if (statement.getText().contains("data=")) return;

    PsiElement identifier =
        PsiTreeUtil.findChildOfType(statement, SoyTemplateReferenceIdentifier.class);

    if (identifier == null) return;

    List<String> requiredParameters =
        ParamUtils.getParametersForInvocation(statement, identifier.getText())
            .stream()
            .filter((var) -> !var.isOptional)
            .map((var) -> var.name)
            .collect(Collectors.toList());

    if (!givenParameters.containsAll(requiredParameters)) {
      requiredParameters.removeAll(givenParameters);
      annotationHolder.createErrorAnnotation(
          identifier, "Missing required parameters: " + String.join(",", requiredParameters));
    }
  }
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:30,代碼來源:MissingParametersAnnotator.java

示例12: isSameCollection

import java.util.Collection; //導入方法依賴的package包/類
public static boolean isSameCollection(Collection<?> newCollection, Collection<?> oldCollection) {
    if (newCollection == null || newCollection.isEmpty()) {
        return true;
    } else if (oldCollection != null) {
        if (newCollection.containsAll(oldCollection) && oldCollection.containsAll(newCollection)) {
            return true;
        } else {
            return false;
        }
    }
    return false;
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:13,代碼來源:CollectionUtils.java

示例13: collectionsAreEqual

import java.util.Collection; //導入方法依賴的package包/類
private boolean collectionsAreEqual(Collection<Coords> a, Collection<Coords> b) {
	return a.containsAll(b) && b.containsAll(a);
}
 
開發者ID:GoSuji,項目名稱:Suji,代碼行數:4,代碼來源:EventScorer.java

示例14: equals

import java.util.Collection; //導入方法依賴的package包/類
@Override
public boolean equals(Object obj) {
    boolean result = false;

    // Check for reflexivity first.
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof DBTable)) {
        return false;
    }

    result = super.equals(obj);

    if (!result) {
        return result;
    }

    // Check for castability (also deals with null obj)
    if (obj instanceof DBTable) {
        DBTable aTable = (DBTable) obj;
        String aTableName = aTable.getName();
        Map<String, DBColumn> aTableColumns = aTable.getColumns();
        DBPrimaryKey aTablePK = aTable.primaryKey;
        List<DBForeignKey> aTableFKs = aTable.getForeignKeys();

        result &= (aTableName != null && name != null && name.equals(aTableName));
        if (columns != null && aTableColumns != null) {
            Set<String> objCols = aTableColumns.keySet();
            Set<String> myCols = columns.keySet();

            // Must be identical (no subsetting), hence the pair of tests.
            result &= myCols.containsAll(objCols) && objCols.containsAll(myCols);
        } else if (!(columns == null && aTableColumns == null)) {
            result = false;
        }

        result &= (primaryKey != null) ? primaryKey.equals(aTablePK) : aTablePK == null;
        if (foreignKeys != null && aTableFKs != null) {
            Collection<DBForeignKey> myFKs = foreignKeys.values();
            // Must be identical (no subsetting), hence the pair of tests.
            result &= myFKs.containsAll(aTableFKs) && aTableFKs.containsAll(myFKs);
        } else if (!(foreignKeys == null && aTableFKs == null)) {
            result = false;
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,代碼來源:DBTable.java

示例15: addStreamTasks

import java.util.Collection; //導入方法依賴的package包/類
private void addStreamTasks(final Collection<TopicPartition> assignment, final long start) {
    if (partitionAssignor == null) {
        throw new IllegalStateException(logPrefix + " Partition assignor has not been initialized while adding stream tasks: this should not happen.");
    }

    final Map<TaskId, Set<TopicPartition>> newTasks = new HashMap<>();

    // collect newly assigned tasks and reopen re-assigned tasks
    log.info("{} Adding assigned tasks as active {}", logPrefix, partitionAssignor.activeTasks());
    for (final Map.Entry<TaskId, Set<TopicPartition>> entry : partitionAssignor.activeTasks().entrySet()) {
        final TaskId taskId = entry.getKey();
        final Set<TopicPartition> partitions = entry.getValue();

        if (assignment.containsAll(partitions)) {
            try {
                final StreamTask task = findMatchingSuspendedTask(taskId, partitions);
                if (task != null) {
                    suspendedTasks.remove(taskId);
                    task.resume();

                    activeTasks.put(taskId, task);

                    for (final TopicPartition partition : partitions) {
                        activeTasksByPartition.put(partition, task);
                    }
                } else {
                    newTasks.put(taskId, partitions);
                }
            } catch (final StreamsException e) {
                log.error("{} Failed to create an active task {}: ", logPrefix, taskId, e);
                throw e;
            }
        } else {
            log.warn("{} Task {} owned partitions {} are not contained in the assignment {}", logPrefix, taskId, partitions, assignment);
        }
    }

    // create all newly assigned tasks (guard against race condition with other thread via backoff and retry)
    // -> other thread will call removeSuspendedTasks(); eventually
    log.debug("{} New active tasks to be created: {}", logPrefix, newTasks);

    taskCreator.retryWithBackoff(newTasks, start);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:44,代碼來源:StreamThread.java


注:本文中的java.util.Collection.containsAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。