本文整理汇总了Java中java.util.Collection.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.equals方法的具体用法?Java Collection.equals怎么用?Java Collection.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import java.util.Collection; //导入方法依赖的package包/类
/**
* Compare if two NameValue lists are equal.
*
* @param otherObject is the object to compare to.
* @return true if the two objects compare for equality.
*/
public boolean equals(Object otherObject) {
if ( otherObject == null ) {
return false;
}
if (!otherObject.getClass().equals(this.getClass())) {
return false;
}
DuplicateNameValueList other = (DuplicateNameValueList) otherObject;
if (nameValueMap.size() != other.nameValueMap.size()) {
return false;
}
Iterator<String> li = this.nameValueMap.keySet().iterator();
while (li.hasNext()) {
String key = (String) li.next();
Collection nv1 = this.getNameValue(key);
Collection nv2 = (Collection) other.nameValueMap.get(key);
if (nv2 == null)
return false;
else if (!nv2.equals(nv1))
return false;
}
return true;
}
示例2: test
import java.util.Collection; //导入方法依赖的package包/类
public void test() throws Exception {
CustomPlugin plugin = new CustomPlugin();
PluginRepository.registerPlugin(plugin);
List<Plugin> plugins = new ArrayList<>();
plugins.add(createPlugin(CustomPlugin.NAME));
ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new Jlink.PluginsConfiguration(plugins,
null, null));
ResourcePoolManager inResources = new ResourcePoolManager(ByteOrder.nativeOrder(), new CustomStringTable());
inResources.add(ResourcePoolEntry.create("/aaa/bbb/res1.class", new byte[90]));
inResources.add(ResourcePoolEntry.create("/aaa/bbb/res2.class", new byte[90]));
inResources.add(ResourcePoolEntry.create("/aaa/bbb/res3.class", new byte[90]));
inResources.add(ResourcePoolEntry.create("/aaa/ddd/res1.class", new byte[90]));
inResources.add(ResourcePoolEntry.create("/aaa/res1.class", new byte[90]));
ResourcePool outResources = stack.visitResources(inResources);
Collection<String> input = inResources.entries()
.map(Object::toString)
.collect(Collectors.toList());
Collection<String> output = outResources.entries()
.map(Object::toString)
.collect(Collectors.toList());
if (!input.equals(output)) {
throw new AssertionError("Input and output resources differ: input: "
+ input + ", output: " + output);
}
}
示例3: assertNotifiedFiles
import java.util.Collection; //导入方法依赖的package包/类
protected void assertNotifiedFiles(File... files) {
Collection<File> sortedExpectedFiles = relativizeAndSortFiles(files);
Collection<File> sortedNotifierFiles = relativizeAndSortFiles(fileNotifyListener.getFiles());
if (!sortedExpectedFiles.equals(sortedNotifierFiles)) {
// we will be fine if at least all given files were notified ...
boolean weAreFine = true;
for (File f : sortedExpectedFiles) {
if(!sortedNotifierFiles.contains(f)) {
weAreFine = false;
break;
}
}
if(weAreFine) return;
String expectedNames = makeFilesList(sortedExpectedFiles);
String actualNames = makeFilesList(sortedNotifierFiles);
System.err.println("Expected files: " + expectedNames);
System.err.println("Notifier files: " + actualNames);
String failureMsg = format("File lists do not match:", expectedNames, actualNames);
Subversion.LOG.warning("assertNotifiedFiles: " + failureMsg);
fail(failureMsg);
}
}
示例4: refreshTasks
import java.util.Collection; //导入方法依赖的package包/类
/**
* @return <code>true</code> if the tasks really changed
*/
boolean refreshTasks () throws CoreException {
Collection<LocalTask> oldTasks = getCache().getAllTasks();
for (NbTask task : MylynSupport.getInstance().getTasks(taskRepository)) {
getLocalTask(task);
}
initialized = true;
return !oldTasks.equals(getCache().getAllTasks());
}
示例5: compatible
import java.util.Collection; //导入方法依赖的package包/类
/**
* Return true if two pdx types have same class name and the same fields but, unlike equals, field
* order does not matter. Note a type that expects a domain class can be compatible with one that
* does not expect a domain class.
*
* @param other the other pdx type
* @return true if two pdx types are compatible.
*/
public boolean compatible(PdxType other) {
if (other == null)
return false;
if (!getClassName().equals(other.getClassName())) {
return false;
}
Collection<PdxField> myFields = getSortedFields();
Collection<PdxField> otherFields = other.getSortedFields();
return myFields.equals(otherFields);
}
示例6: getListCellRendererComponent
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean selected, boolean hasFocus) {
AbstractSummaryView.RevisionItem item = (AbstractSummaryView.RevisionItem) value;
AbstractSummaryView.LogEntry entry = item.getUserData();
Collection<SearchHighlight> highlights = summaryView.getMaster().getSearchHighlights();
if (revisionCell.getRevisionControl().getStyledDocument().getLength() == 0 || revisionCell.getDateControl().getStyledDocument().getLength() == 0 || revisionCell.getAuthorControl().getStyledDocument().getLength() == 0 || revisionCell.getCommitMessageControl().getStyledDocument().getLength() == 0 || selected != lastSelection || item.messageExpanded != lastMessageExpanded || item.revisionExpanded != lastRevisionExpanded
|| !highlights.equals(lastHighlights)) {
lastSelection = selected;
lastMessageExpanded = item.messageExpanded;
lastRevisionExpanded = item.revisionExpanded;
lastHighlights = highlights;
Color backgroundColor;
if (selected) {
backgroundColor = selectionBackground;
} else {
backgroundColor = UIManager.getColor("List.background"); //NOI18N
backgroundColor = entry.isLessInteresting() ? darkerUninteresting(backgroundColor) : darker(backgroundColor);
}
this.setBackground(backgroundColor);
revisionCell.setBackground(backgroundColor);
if (item.revisionExpanded) {
expandButton.setIcon(ICON_EXPANDED);
} else {
expandButton.setIcon(ICON_COLLAPSED);
}
id = item.getItemId();
if (linkerSupport.getLinker(ExpandLink.class, id) == null) {
linkerSupport.add(new ExpandLink(item), id);
}
try {
addRevision(revisionCell.getRevisionControl(), item, selected, highlights);
addCommitMessage(revisionCell.getCommitMessageControl(), item, selected, highlights);
addAuthor(revisionCell.getAuthorControl(), item, selected, highlights);
addDate(revisionCell.getDateControl(), item, selected, highlights);
} catch (BadLocationException e) {
ErrorManager.getDefault().notify(e);
}
}
lastWidth = resizePane(revisionCell.getCommitMessageControl().getText(), list, lastWidth);
return this;
}
示例7: refreshEntry
import java.util.Collection; //导入方法依赖的package包/类
/** Refreshes content of one entry. Updates the state of children
* appropriately.
*/
final void refreshEntry(Entry entry) {
// current list of nodes
ChildrenArray holder = array.get();
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("refreshEntry: " + entry + " holder=" + holder);
}
if (holder == null) {
return;
}
Node[] current = holder.nodes();
if (current == null) {
// the initialization is not finished yet =>
return;
}
checkConsistency();
Info info = map.get(entry);
if (info == null) {
// refresh of entry that is not present =>
return;
}
Collection<Node> oldNodes = info.nodes(false);
Collection<Node> newNodes = info.entry.nodes(null);
if (oldNodes.equals(newNodes)) {
// nodes are the same =>
return;
}
Set<Node> toRemove = new HashSet<Node>(oldNodes);
toRemove.removeAll(new HashSet<Node>(newNodes));
if (!toRemove.isEmpty()) {
// notify removing, the set must be ready for
// callbacks with questions
// modifies the list associated with the info
oldNodes.removeAll(toRemove);
clearNodes();
// now everything should be consistent => notify the remove
notifyRemove(toRemove, current);
current = holder.nodes();
}
List<Node> toAdd = refreshOrder(entry, oldNodes, newNodes);
info.useNodes(newNodes);
if (!toAdd.isEmpty()) {
// modifies the list associated with the info
clearNodes();
notifyAdd(toAdd);
}
}