本文整理汇总了Java中java.util.List.equals方法的典型用法代码示例。如果您正苦于以下问题:Java List.equals方法的具体用法?Java List.equals怎么用?Java List.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.List
的用法示例。
在下文中一共展示了List.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isMethodInRequestOptions
import java.util.List; //导入方法依赖的package包/类
private boolean isMethodInRequestOptions(ExecutableElement toFind) {
// toFind is a method in a GlideExtension whose first argument is a BaseRequestOptions<?> type.
// Since we're comparing against methods in BaseRequestOptions itself, we need to drop that
// first type.
List<String> toFindParameterNames = getComparableParameterNames(toFind, true /*skipFirst*/);
String toFindSimpleName = toFind.getSimpleName().toString();
for (Element element : requestOptionsType.getEnclosedElements()) {
if (element.getKind() != ElementKind.METHOD) {
continue;
}
ExecutableElement inBase = (ExecutableElement) element;
if (toFindSimpleName.equals(inBase.getSimpleName().toString())) {
List<String> parameterNamesInBase =
getComparableParameterNames(inBase, false /*skipFirst*/);
if (parameterNamesInBase.equals(toFindParameterNames)) {
return true;
}
}
}
return false;
}
示例2: test2
import java.util.List; //导入方法依赖的package包/类
/**
* Verifies that SystemFlavorMap is not affected by modification of
* the Lists returned from getNativesForFlavor() and
* getFlavorsForNative().
*/
public static void test2() {
DataFlavor df = new DataFlavor("text/plain-test2", null);
String nat = "native2";
DataFlavor extraDf = new DataFlavor("text/test", null);
List<String> natives = fm.getNativesForFlavor(df);
natives.add("Should not be here");
java.util.List nativesNew = fm.getNativesForFlavor(df);
if (natives.equals(nativesNew)) {
System.err.println("orig=" + natives);
System.err.println("new=" + nativesNew);
throw new RuntimeException("Test failed");
}
List<DataFlavor> flavors = fm.getFlavorsForNative(nat);
flavors.add(extraDf);
java.util.List flavorsNew = fm.getFlavorsForNative(nat);
if (flavors.equals(flavorsNew)) {
System.err.println("orig=" + flavors);
System.err.println("new=" + flavorsNew);
throw new RuntimeException("Test failed");
}
}
示例3: testUseOnlyOneProcessor
import java.util.List; //导入方法依赖的package包/类
@Test
public void testUseOnlyOneProcessor(Path base) throws Exception {
initialization(base);
List<String> log = new JavacTask(tb)
.options("--processor-module-path", processorCompiledModules.toString(),
"-Xplugin:simpleplugin1")
.outdir(classes)
.sources(testClass)
.run()
.writeAll()
.getOutputLines(Task.OutputKind.STDOUT);
if (!log.equals(Arrays.asList("simpleplugin1 started for event COMPILATION",
"simpleplugin1 finished for event COMPILATION"))) {
throw new AssertionError("Unexpected output: " + log);
}
}
示例4: checkDiags
import java.util.List; //导入方法依赖的package包/类
void checkDiags(String msg, List<Diagnostic<? extends JavaFileObject>> diags, List<String> expectDiagCodes) {
System.err.print(msg);
if (diags.isEmpty())
System.err.println(" OK");
else {
System.err.println();
System.err.println(diags);
}
List<String> foundDiagCodes = new ArrayList<String>();
for (Diagnostic<? extends JavaFileObject> d: diags)
foundDiagCodes.add(d.getCode());
if (!foundDiagCodes.equals(expectDiagCodes)) {
System.err.println("Found diag codes: " + foundDiagCodes);
System.err.println("Expected diag codes: " + expectDiagCodes);
error("expected diagnostics not found");
}
}
示例5: compareValues
import java.util.List; //导入方法依赖的package包/类
/**
* Compares two values, paying attention to the order of the elements.
* @return true if the values are different
*/
// TODO improve efficiency for the array case?
@Override
@SuppressWarnings("unchecked")
protected boolean compareValues(Object previous, Object value)
{
int prevSize = __getSize(previous);
int newSize = __getSize(value);
// If the sizes are different, no need to bother with further work
if (prevSize != newSize)
return true;
// If the sizes are the same, and they're empty, we're also done.
if (prevSize == 0)
return false;
List<Object> prevList = (previous instanceof List)
? (List<Object>) previous : __toList(previous);
List<Object> newList = (value instanceof List)
? (List<Object>) value : __toList(value);
// Since List has explicit rules about how equals() works, we
// can just use that method.
return !prevList.equals(newList);
}
示例6: extendStringToMatchByOneCharacter
import java.util.List; //导入方法依赖的package包/类
private void extendStringToMatchByOneCharacter(final char c) {
final List<Head> newHeads = listForLocalUseage;
newHeads.clear();
List<Head> lastAddedHeads = null;
for(final Head head : heads) {
final List<Head> headsToAdd = head.getNextHeads(c);
// Why the next performance optimization isn't wrong:
// Some times two heads return the very same list.
// We save future effort if we don't add these heads again.
// This is the case with the heads "a" and "*" of "a*b" which
// both can return the list ["*","b"]
if(!headsToAdd.equals(lastAddedHeads)) {
newHeads.addAll(headsToAdd);
lastAddedHeads = headsToAdd;
}
}
listForLocalUseage = heads;
heads = newHeads;
}
示例7: doArgumentCheck
import java.util.List; //导入方法依赖的package包/类
void doArgumentCheck(String inArgs, String... expArgs) {
Map<String, String> env = new HashMap<>();
env.put(JLDEBUG_KEY, "true");
TestResult tr = doExec(env, javaCmd, inArgs);
System.out.println(tr);
int sindex = tr.testOutput.indexOf("Command line args:");
if (sindex < 0) {
System.out.println(tr);
throw new RuntimeException("Error: no output");
}
sindex++; // skip over the tag
List<String> gotList = new ArrayList<>();
for (String x : tr.testOutput.subList(sindex, sindex + expArgs.length)) {
String a[] = x.split("=");
gotList.add(a[a.length - 1].trim());
}
List<String> expList = Arrays.asList(expArgs);
if (!gotList.equals(expList)) {
System.out.println(tr);
System.out.println("Expected args:");
System.out.println(expList);
System.out.println("Obtained args:");
System.out.println(gotList);
throw new RuntimeException("Error: args do not match");
}
}
示例8: testUnsafeUnnamed
import java.util.List; //导入方法依赖的package包/类
@Test
public void testUnsafeUnnamed(Path base) throws IOException {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"package test; public class Test { sun.misc.Unsafe unsafe; } ");
Path classes = base.resolve("classes");
tb.createDirectories(classes);
List<String> log;
List<String> expected = Arrays.asList(
"Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe",
"1 warning"
);
log = new JavacTask(tb)
.options("-XDrawDiagnostics")
.outdir(classes)
.files(tb.findJavaFiles(src))
.run(Expect.SUCCESS)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
if (!expected.equals(log)) {
throw new AssertionError("Unexpected output: " + log);
}
log = new JavacTask(tb)
.options("-XDrawDiagnostics",
"--release", Target.DEFAULT.multiReleaseValue())
.outdir(classes)
.files(tb.findJavaFiles(src))
.run(Expect.SUCCESS)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
if (!expected.equals(log)) {
throw new AssertionError("Unexpected output: " + log);
}
}
示例9: rewriteChildren
import java.util.List; //导入方法依赖的package包/类
protected final ModifiersTree rewriteChildren(ModifiersTree tree) {
List<? extends AnnotationTree> annotations = translateStable(tree.getAnnotations());
if (!annotations.equals(tree.getAnnotations())) {
ModifiersTree n = make.Modifiers(tree, annotations);
model.setType(n, model.getType(tree));
copyCommentTo(tree,n);
copyPosTo(tree,n);
tree = n;
}
return tree;
}
示例10: testInaccessibleUnnamedModule
import java.util.List; //导入方法依赖的package包/类
public void testInaccessibleUnnamedModule(Path base) throws Exception {
Path jar = prepareTestJar(base, "package api; class Api { public static class Foo {} }");
Path moduleSrc = base.resolve("module-src");
Path m1x = moduleSrc.resolve("m1x");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
tb.writeJavaFiles(m1x,
"module m1x { }",
"package test; public class Test { api.Api api; api.Api.Foo api; }");
List<String> log = new JavacTask(tb)
.options("-classpath", jar.toString(),
"-XDrawDiagnostics")
.outdir(classes)
.files(findJavaFiles(moduleSrc))
.run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expected = Arrays.asList(
"Test.java:1:38: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)",
"Test.java:1:51: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)",
"2 errors");
if (!expected.equals(log))
throw new Exception("expected output not found; actual: " + log);
}
示例11: processInstanceLists
import java.util.List; //导入方法依赖的package包/类
private void processInstanceLists(JSONObject instanceLists){
try {
joinedInstances = JsonUtil.getStringListFromJsonArray(instanceLists.
getJSONArray(JOINED_LIST_KEY));
publicInstances = JsonUtil.getStringListFromJsonArray(instanceLists.
getJSONArray(PUBLIC_LIST_KEY));
List<String> receivedInstancesInvited = JsonUtil.getStringListFromJsonArray(instanceLists.
getJSONArray(INVITED_LIST_KEY));
if (!receivedInstancesInvited.equals(InvitedInstances())) {
List<String> oldList = invitedInstances;
invitedInstances = receivedInstancesInvited;
List<String> newInvites = new ArrayList<String>(receivedInstancesInvited);
newInvites.removeAll(oldList);
for (final String instanceInvited : newInvites) {
Invited(instanceInvited);
}
}
} catch (JSONException e) {
Log.w(LOG_TAG, e);
Info("Instance lists failed to parse.");
}
}
示例12: updateExtraWizardPanels
import java.util.List; //导入方法依赖的package包/类
private void updateExtraWizardPanels() {
List<WizardDescriptor.Panel<WizardDescriptor>> l = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
if (getCurrent() == workspacePanel) {
numberOfPanels = workspacePanel.isWorkspaceChosen() ? 2 : 1;
}
if (getCurrent() != projectPanel) {
return;
}
Set<String> alreadyIncluded = new HashSet<String>();
List<String> panelProviders = new ArrayList<String>();
for (EclipseProject ep : getProjects()) {
if (!ep.isImportSupported()) {
continue;
}
if (alreadyIncluded.contains(ep.getProjectTypeFactory().getClass().getName())) {
continue;
} else {
alreadyIncluded.add(ep.getProjectTypeFactory().getClass().getName());
}
l.addAll(ep.getProjectTypeFactory().getAdditionalImportWizardPanels());
panelProviders.add(ep.getProjectTypeFactory().getClass().getName());
}
if (panelProviders.equals(currentPanelProviders)) {
return;
} else {
currentPanelProviders = panelProviders;
}
extraPanels = l;
numberOfPanels = 2 + l.size();
int index = 2;
for (WizardDescriptor.Panel p : l) {
JComponent comp = (JComponent)p.getComponent();
comp.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, // NOI18N
new Integer(index));
index++;
comp.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, getWizardPanelName(l));
}
((JComponent)projectPanel.getComponent()).putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, getWizardPanelName(l));
}
示例13: patchCreatesNewFileThatAlreadyExists
import java.util.List; //导入方法依赖的package包/类
private boolean patchCreatesNewFileThatAlreadyExists(SinglePatch patch, List<String> originalFile) throws PatchException {
if (patch.hunks.length != 1) {
return false;
}
Hunk hunk = patch.hunks[0];
if (hunk.baseStart != 0 || hunk.baseCount != 0 || hunk.modifiedStart
!= 1 || hunk.modifiedCount != originalFile.size()) {
return false;
}
List<String> target = new ArrayList<>(hunk.modifiedCount);
applyHunk(target, hunk);
return target.equals(originalFile);
}
示例14: checkArgumentParsing
import java.util.List; //导入方法依赖的package包/类
void checkArgumentParsing(String inArgs, String... expArgs) throws IOException {
List<String> scratchpad = new ArrayList<>();
scratchpad.add("set " + JLDEBUG_KEY + "=true");
// GAK, -version needs to be added so that windows can flush its stderr
// exiting the process prematurely can terminate the stderr.
scratchpad.add(javaCmd + " -version " + inArgs);
File batFile = new File("atest.bat");
createAFile(batFile, scratchpad);
TestResult tr = doExec(batFile.getName());
ArrayList<String> expList = new ArrayList<>();
expList.add(javaCmd);
expList.add("-version");
expList.addAll(Arrays.asList(expArgs));
List<String> gotList = new ArrayList<>();
for (String x : tr.testOutput) {
Matcher m = ArgPattern.matcher(x);
if (m.matches()) {
String a[] = x.split("=");
gotList.add(a[a.length - 1].trim());
}
}
if (!gotList.equals(expList)) {
System.out.println(tr);
System.out.println("Expected args:");
System.out.println(expList);
System.out.println("Obtained args:");
System.out.println(gotList);
throw new RuntimeException("Error: args do not match");
}
System.out.println("\'" + inArgs + "\'" + " - Test passed");
}
示例15: dropArgumentsToMatch
import java.util.List; //导入方法依赖的package包/类
private static MethodHandle dropArgumentsToMatch(MethodHandle target, int skip, List<Class<?>> newTypes, int pos,
boolean nullOnFailure) {
newTypes = copyTypes(newTypes.toArray());
List<Class<?>> oldTypes = target.type().parameterList();
int match = oldTypes.size();
if (skip != 0) {
if (skip < 0 || skip > match) {
throw newIllegalArgumentException("illegal skip", skip, target);
}
oldTypes = oldTypes.subList(skip, match);
match -= skip;
}
List<Class<?>> addTypes = newTypes;
int add = addTypes.size();
if (pos != 0) {
if (pos < 0 || pos > add) {
throw newIllegalArgumentException("illegal pos", pos, newTypes);
}
addTypes = addTypes.subList(pos, add);
add -= pos;
assert(addTypes.size() == add);
}
// Do not add types which already match the existing arguments.
if (match > add || !oldTypes.equals(addTypes.subList(0, match))) {
if (nullOnFailure) {
return null;
}
throw newIllegalArgumentException("argument lists do not match", oldTypes, newTypes);
}
addTypes = addTypes.subList(match, add);
add -= match;
assert(addTypes.size() == add);
// newTypes: ( P*[pos], M*[match], A*[add] )
// target: ( S*[skip], M*[match] )
MethodHandle adapter = target;
if (add > 0) {
adapter = dropArguments0(adapter, skip+ match, addTypes);
}
// adapter: (S*[skip], M*[match], A*[add] )
if (pos > 0) {
adapter = dropArguments0(adapter, skip, newTypes.subList(0, pos));
}
// adapter: (S*[skip], P*[pos], M*[match], A*[add] )
return adapter;
}