本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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 + ")");
}
示例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);
}
示例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);
}
示例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));
}
}
}
示例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;
}
示例13: collectionsAreEqual
import java.util.Collection; //导入方法依赖的package包/类
private boolean collectionsAreEqual(Collection<Coords> a, Collection<Coords> b) {
return a.containsAll(b) && b.containsAll(a);
}
示例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;
}
示例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);
}