本文整理匯總了Java中java.util.List.containsAll方法的典型用法代碼示例。如果您正苦於以下問題:Java List.containsAll方法的具體用法?Java List.containsAll怎麽用?Java List.containsAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.List
的用法示例。
在下文中一共展示了List.containsAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testDuplicateImplementations2
import java.util.List; //導入方法依賴的package包/類
@Test
public void testDuplicateImplementations2(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { exports p1; provides p1.C1 with p2.C2; provides p1.C1 with p2.C2; }",
"package p1; public class C1 { }",
"package p2; public class C2 extends p1.C1 { }");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
List<String> output = new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(classes)
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expected = Arrays.asList(
"module-info.java:1:62: compiler.err.repeated.provides.for.service: p1.C1",
"module-info.java:1:73: compiler.err.duplicate.provides: p1.C1, p2.C2",
"2 errors");
if (!output.containsAll(expected)) {
throw new Exception("Expected output not found");
}
}
示例2: mainCheck
import java.util.List; //導入方法依賴的package包/類
public static boolean mainCheck(AStarHeap heap, Integer[] nums){
System.out.println("Removing and checking " + mainToStr(nums));
List heapInts = new ArrayList();
List desiredInts = new ArrayList();
for (int i = 0; i < nums.length; ++i){
desiredInts.add(nums[i]);
heapInts.add(heap.getMin());
heap.deleteMin();
}
if ( heapInts.containsAll(desiredInts) ){
System.out.println("OK");
return true;
} else {
System.out.println("KO!");
System.exit(1);
}
return false;
}
示例3: testNoNoArgConstructor
import java.util.List; //導入方法依賴的package包/類
@Test
public void testNoNoArgConstructor(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p1.C1; provides p1.C1 with p2.C2; }",
"package p1; public class C1 { }",
"package p2; public class C2 extends p1.C1 { public C2(String str) { } }");
List<String> output = new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(Files.createDirectories(base.resolve("classes")))
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expected = Arrays.asList(
"module-info.java:1:46: compiler.err.service.implementation.doesnt.have.a.no.args.constructor: p2.C2");
if (!output.containsAll(expected)) {
throw new Exception("Expected output not found");
}
}
示例4: testDuplicateUses
import java.util.List; //導入方法依賴的package包/類
@Test
public void testDuplicateUses(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m"),
"module m { uses p.C; uses p.C; }",
"package p; public class C { }");
List<String> output = new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(Files.createDirectories(base.resolve("classes")))
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
if (!output.containsAll(Arrays.asList(
"module-info.java:1:22: compiler.err.duplicate.uses: p.C"))) {
throw new Exception("Expected output not found");
}
}
示例5: testMissingService
import java.util.List; //導入方法依賴的package包/類
@Test
public void testMissingService(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.Missing with p.C; }",
"package p; public class C extends p.Missing { }");
List<String> output = new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(Files.createDirectories(base.resolve("classes")))
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expected = Arrays.asList(
"C.java:1:36: compiler.err.cant.resolve.location: kindname.class, Missing, , , (compiler.misc.location: kindname.package, p, null)",
"module-info.java:1:22: compiler.err.cant.resolve.location: kindname.class, Missing, , , (compiler.misc.location: kindname.package, p, null)",
"2 errors");
if (!output.containsAll(expected)) {
throw new Exception("Expected output not found");
}
}
示例6: removeTargets
import java.util.List; //導入方法依賴的package包/類
public static void removeTargets(Object transitionObject, ArrayList<View> views) {
Transition transition = (Transition) transitionObject;
int i;
if (transition instanceof TransitionSet) {
TransitionSet set = (TransitionSet) transition;
int numTransitions = set.getTransitionCount();
for (i = 0; i < numTransitions; i++) {
removeTargets(set.getTransitionAt(i), views);
}
} else if (!hasSimpleTarget(transition)) {
List<View> targets = transition.getTargets();
if (targets != null && targets.size() == views.size() && targets.containsAll(views)) {
for (i = views.size() - 1; i >= 0; i--) {
transition.removeTarget((View) views.get(i));
}
}
}
}
示例7: updateFields
import java.util.List; //導入方法依賴的package包/類
public boolean updateFields(
List<SquidSpeciesModel> squidSpeciesSpecsList,
List<SquidRatiosModel> squidRatiosSpecsList,
boolean useSBM, boolean userLinFits,
int indexOfBackgroundSpecies,
String referenceMaterialNameFilter,
String concentrationReferenceMaterialNameFilter) {
boolean retVal = false;
retVal = !(this.squidSpeciesModelList.containsAll(squidSpeciesSpecsList) && squidSpeciesSpecsList.containsAll(this.squidSpeciesModelList));
if (!retVal) {
retVal = !(this.squidRatiosModelList.containsAll(squidRatiosSpecsList) && squidRatiosSpecsList.containsAll(this.squidRatiosModelList));
}
if (!retVal) {
retVal = !(this.useSBM == useSBM);
}
if (!retVal) {
retVal = !(this.userLinFits == userLinFits);
}
if (!retVal) {
retVal = !(this.indexOfBackgroundSpecies == indexOfBackgroundSpecies);
}
if (!retVal) {
retVal = !(this.referenceMaterialNameFilter.compareToIgnoreCase(referenceMaterialNameFilter) == 0);
}
if (!retVal) {
retVal = !(this.concentrationReferenceMaterialNameFilter.compareToIgnoreCase(concentrationReferenceMaterialNameFilter) == 0);
}
return retVal;
}
示例8: checkPrems
import java.util.List; //導入方法依賴的package包/類
/**
* 檢查權限是否越權
*/
private void checkPrems(SysRoleEntity role) {
//如果不是超級管理員,則需要判斷角色的權限是否超過自己的權限
if (role.getCreateUserId() == Constant.SUPER_ADMIN) {
return;
}
//查詢用戶所擁有的菜單列表
List<Long> menuIdList = sysUserService.queryAllMenuId(role.getCreateUserId());
//判斷是否越權
if (!menuIdList.containsAll(role.getMenuIdList())) {
throw new RRException("新增角色的權限,已超出你的權限範圍");
}
}
示例9: checkAttributes
import java.util.List; //導入方法依賴的package包/類
private static void checkAttributes(LoggingMXBean mxbean1,
PlatformLoggingMXBean mxbean2) {
// verify logger names
List<String> loggers1 = mxbean1.getLoggerNames();
System.out.println("Loggers: " + loggers1);
// Retrieve the named loggers to prevent them from being
// spontaneously gc'ed.
Map<String, Logger> loggersMap = new HashMap<>();
for (String n : loggers1) {
loggersMap.put(n, Logger.getLogger(n));
}
List<String> loggers2 = mxbean2.getLoggerNames();
// loggers1 and loggers2 should be identical - no new logger should
// have been created in between (at least no new logger name)
//
if (loggers1.size() != loggers2.size())
throw new RuntimeException("LoggerNames: unmatched number of entries");
if (!loggers2.containsAll(loggersMap.keySet()))
throw new RuntimeException("LoggerNames: unmatched loggers");
// verify logger's level and parent
for (String logger : loggers1) {
String level1 = mxbean1.getLoggerLevel(logger);
String level2 = mxbean2.getLoggerLevel(logger);
if (!java.util.Objects.equals(level1, level2)) {
throw new RuntimeException(
"LoggerLevel: unmatched level for " + logger
+ ", " + level1 + ", " + level2);
}
if (!mxbean1.getParentLoggerName(logger)
.equals(mxbean2.getParentLoggerName(logger)))
throw new RuntimeException(
"ParentLoggerName: unmatched parent logger's name for " + logger);
}
}
示例10: compareArrVals
import java.util.List; //導入方法依賴的package包/類
private boolean compareArrVals(Annotation[] actualAnnos, String[] expectedAnnos) {
// Look if test case was run.
if (actualAnnos == specialAnnoArray) {
return false; // no testcase matches
}
if (actualAnnos.length != expectedAnnos.length) {
System.out.println("Length not same. "
+ " actualAnnos length = " + actualAnnos.length
+ " expectedAnnos length = " + expectedAnnos.length);
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
} else {
int i = 0;
String[] actualArr = new String[actualAnnos.length];
for (Annotation a : actualAnnos) {
actualArr[i++] = a.toString();
}
List<String> actualList = Arrays.asList(actualArr);
List<String> expectedList = Arrays.asList(expectedAnnos);
if (!actualList.containsAll(expectedList)) {
System.out.println("Array values are not same");
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
}
}
return true;
}
示例11: calc
import java.util.List; //導入方法依賴的package包/類
public void calc(boolean plot, String gptCols, String plotFile) {
if (plot) {
FileHandler.writeMatrixWithId(neurons, destDir + neuronsFile, separator);
FileHandler.appendColumn(srcFilePath, destDir + destFile, separator, winnerIds);
String cmd = "gnuplot -c " + System.getProperty("user.dir") + "/" + plotFile + " " + gptCols;
Utils.rumCmd(cmd);
}
List<List<Double>> prevDataPoints = new ArrayList<List<Double>>();
for (int i = 0; i < iterations; i++) {
prevDataPoints = neurons;
calcWinnersIds();
learn(i);
if (plot) {
FileHandler.writeMatrixWithId(neurons, destDir + neuronsFile, separator);
FileHandler.appendColumn(srcFilePath, destDir + destFile, separator, winnerIds);
}
if (prevDataPoints.containsAll(neurons) && neurons.containsAll(prevDataPoints)) {
break;
}
System.out.println(i);
}
FileHandler.writePointsAsClusters(winnerIds, neurons, destDir + imgcprFile, separator);
}
示例12: testImplementationMustBeInSameModuleAsProvidesDirective
import java.util.List; //導入方法依賴的package包/類
@Test
public void testImplementationMustBeInSameModuleAsProvidesDirective(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1x"),
"module m1x { exports p1; }",
"package p1; public class C1 { }");
tb.writeJavaFiles(src.resolve("m2x"),
"module m2x { requires m1x; requires m3x; provides p1.C1 with p2.C2; }");
tb.writeJavaFiles(src.resolve("m3x"),
"module m3x { requires m1x; exports p2; }",
"package p2; public class C2 extends p1.C1 { }");
Path modules = base.resolve("modules");
Files.createDirectories(modules);
List<String> output = new JavacTask(tb)
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
.outdir(modules)
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expected = Arrays.asList(
"module-info.java:1:42: compiler.err.service.implementation.not.in.right.module: m3x",
"1 error");
if (!output.containsAll(expected)) {
throw new Exception("Expected output not found");
}
}
示例13: checkPerms
import java.util.List; //導入方法依賴的package包/類
private static void checkPerms(List<Permission> perms,
Permission... grantedPerms)
throws Exception
{
if (!perms.containsAll(Arrays.asList(grantedPerms))) {
throw new Exception("Granted permissions not correct");
}
}
示例14: testAP2941
import java.util.List; //導入方法依賴的package包/類
public void testAP2941(Binding binding,
BindingOperation bindingOperation,
BindingInput bindingInput,
BindingOutput bindingOutput,
Input portTypeInput,
Output portTypeOutput) {
if (portTypeInput != null && portTypeInput.getMessage() != null) {
// Getting the list of all the parts bound by wsdl:input's child elements
List inputParts = getBindingParts_AP2941(
bindingOperation.getBindingInput().getExtensibilityElements(),
(Message) portTypeInput.getMessage().get());
if (!inputParts.containsAll(getPartNames(((Message) portTypeInput.getMessage().get()).getParts()))) {
mResults.add(new Validator.ResultItem(mValidator,
Validator.ResultType.ERROR,
bindingInput,
NbBundle.getMessage(WSIAPValidator.class, "AP2941")));
}
}
// If the corresponding wsdl:output exists in wsdl:portType
// and includes the message attribute
if (portTypeOutput != null && portTypeOutput.getMessage() != null) {
// Getting the list of all the parts bound by wsdl:output's child elements
List outputParts = getBindingParts_AP2941(
bindingOperation.getBindingOutput().getExtensibilityElements(),
(Message) portTypeOutput.getMessage().get());
if (!outputParts.containsAll(getPartNames(((Message) portTypeOutput.getMessage().get()).getParts()))) {
mResults.add(new Validator.ResultItem(mValidator,
Validator.ResultType.ERROR,
bindingOutput,
NbBundle.getMessage(WSIAPValidator.class, "AP2941")));
}
}
//this logic doesn't seem right due to the fault names or part names
// if (!((Operation) bindingOperation.getOperation().get()).getFaults().isEmpty()) {
// // Collecting all the soap:fault names
// List faultNames = new ArrayList();
// Collection faults = bindingOperation.getBindingFaults();
// // Going through all the wsdl:faultS
// Iterator it = faults.iterator();
// while (it.hasNext()) {
// // Getting wsdl:fault's extensibility elements
// List extElems = ((BindingFault) it.next()).getExtensibilityElements();
// for (int j = 0; j < extElems.size(); j++) {
// if (extElems.get(j) instanceof SOAPFault) {
// faultNames.add(((SOAPFault) extElems.get(j)).getName());
// }
// }
// }
// //soap:fault + soap:headerfault
// Collection <ExtensibilityElement> extEles = new ArrayList<ExtensibilityElement>();
// extEles.addAll(bindingOperation.getBindingInput().getExtensibilityElements());
// extEles.addAll(bindingOperation.getBindingOutput().getExtensibilityElements());
// faultNames.addAll(findAllHeaderFaults(extEles));
//
// // If not true that all the wsdl:faultS are bound,
// // the assertion failed
// if (!faultNames.containsAll(getFaultNames(((Operation) bindingOperation.getOperation().get()).getFaults()))) {
// mResults.add(new Validator.ResultItem(mValidator,
// Validator.ResultType.ERROR,
// bindingOperation,
// //NbBundle.getMessage(WSIAPValidator.class, "AP2901")));
// "AP2941"));
// }
// }
}
示例15: equals
import java.util.List; //導入方法依賴的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;
}