下面列出了java.util.ArrayList#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void saveOwnDNSCryptServersIfChanged(Context context) {
ArrayList<DNSServerItem> newOwnItems = new ArrayList<>();
ArrayList<String> linesReadyToSave = new ArrayList<>();
for (DNSServerItem dnsServerItem: list_dns_servers) {
if (dnsServerItem.getOwnServer()) {
linesReadyToSave.add("## " + dnsServerItem.getName());
linesReadyToSave.add(dnsServerItem.getDescription());
linesReadyToSave.add("sdns://" + dnsServerItem.getSDNS());
newOwnItems.add(dnsServerItem);
}
}
if (newOwnItems.equals(savedOwnDNSCryptServers)) {
return;
}
FileOperations.writeToTextFile(context, ownServersFilePath, linesReadyToSave, "ignored");
}
private ArrayList<Integer> validateArrayInstanitation(ArrayElementGettable ad){
ArrayList<Integer> sizes = new ArrayList<Integer>();
ArrayList<Expression> items = ad.getArrayElements(this);
sizes.add(items.size());
ArrayList<Integer> nextlevelsizes = null;
for(Expression item : items) {
if(item instanceof ArrayDef) {
ArrayList<Integer> nevlevel = validateArrayInstanitation((ArrayDef)item );
if(null == nextlevelsizes) {
nextlevelsizes = nevlevel;
}else {
//ensue match with preoiuvs one
if(!nextlevelsizes.equals(nevlevel)) {
raiseErrorNoUse(((Expression)ad).getLine(), ((Expression)ad).getColumn(), "unequal n dimentional array subarray instantiation");
}
}
}
}
if(null != nextlevelsizes) {
sizes.addAll(nextlevelsizes);
}
return sizes;
}
@Override
public LogicalPlan pruneOutputsExcept(TableStats tableStats, Collection<Symbol> outputsToKeep) {
ArrayList<Symbol> newOutputs = new ArrayList<>();
for (Symbol output : outputs) {
if (outputsToKeep.contains(output)) {
newOutputs.add(output);
}
}
if (newOutputs.equals(outputs)) {
return this;
}
Stats stats = tableStats.getStats(relation.relationName());
return new Collect(
preferSourceLookup,
relation,
newOutputs,
where,
numExpectedRows,
stats.estimateSizeForColumns(newOutputs)
);
}
public void setUnitTypeList(ArrayList<Class<? extends Unit>> utList) {
if (utList.equals(unitTypeList))
return;
// Save the new unit types
unitTypeList = new ArrayList<>(utList);
this.setValid(false);
// Set the units for the default value column in the Input Editor
if (defValue == null)
return;
for (int i=0; i<defValue.size(); i++) {
SampleProvider p = defValue.get(i);
if (p instanceof SampleConstant)
((SampleConstant) p).setUnitType(getUnitType(i));
}
}
public void writeSavableArrayList(ArrayList array, String name, ArrayList defVal) throws IOException {
if (array == null) {
return;
}
if (array.equals(defVal)) {
return;
}
Element old = currentElement;
Element el = appendElement(name);
currentElement = el;
el.setAttribute(XMLExporter.ATTRIBUTE_SIZE, String.valueOf(array.size()));
for (Object o : array) {
if(o == null) {
continue;
}
else if (o instanceof Savable) {
Savable s = (Savable) o;
write(s, s.getClass().getName(), null);
} else {
throw new ClassCastException("Not a Savable instance: " + o);
}
}
currentElement = old;
}
public void copyNavigatorList(ArrayList<Feature> list)
{
if(list.equals(navigatorList))
return;
list.clear();
list.addAll(navigatorList);
}
public void writeFloatBufferArrayList(ArrayList<FloatBuffer> array, String name, ArrayList<FloatBuffer> defVal) throws IOException {
if (array == null) {
return;
}
if (array.equals(defVal)) {
return;
}
Element el = appendElement(name);
el.setAttribute(XMLExporter.ATTRIBUTE_SIZE, String.valueOf(array.size()));
for (FloatBuffer o : array) {
write(o, XMLExporter.ELEMENT_FLOATBUFFER, null);
}
currentElement = (Element) el.getParentNode();
}
private void compareWithExpected(File expected, ArrayList<ErrorHolder> gota) throws Exception
{
BufferedReader br = new BufferedReader(new FileReader(expected));
try
{
ArrayList<String> got = Utils.erListToStrList(gota);
ArrayList<String> expectedErrs = new ArrayList<String>();
String sCurrentLine = null;
while((sCurrentLine = br.readLine()) != null)
{
expectedErrs.add(sCurrentLine);
}
if(!got.equals(expectedErrs))
{
String expStr = listToStr(expectedErrs);
String gotStr = listToStr(got);
throw new junit.framework.ComparisonFailure("Expected messages does not match obtained", expStr, gotStr);
}
}
catch(Exception e)
{
throw e;
}
finally
{
br.close();
}
}
private void doPersistColumnsConfig(ArrayList<Pair<Integer, Integer>> columnsConfig) {
if (columnsConfig.equals(prevColumnsConfig)) {
return;
}
prevColumnsConfig = columnsConfig;
configPairs.put(keyId, columnsConfig);
}
private void setVisibleAgentToWhiteBoard() {
if (whiteBoard != null) {
ArrayList<String> visibleAgentList = mergeRecyclerAdapter.getAgentVisibiltyList();
if (visibleAgentList.size() != oldVisibleAgentList.size() || !visibleAgentList.equals(oldVisibleAgentList)) {
oldVisibleAgentList = visibleAgentList;
whiteBoard.putSerializable(ShieldConst.AGENT_VISIBILITY_LIST_KEY, visibleAgentList);
}
}
}
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
SelectionModel selectionModel = getSelectionModel();
ArrayList<IContentPart<? extends Node>> currentSelection = new ArrayList<>(
selectionModel.getSelectionUnmodifiable());
if (!currentSelection.equals(finalSelection)) {
selectionModel.setSelection(finalSelection);
}
return Status.OK_STATUS;
}
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
SelectionModel selectionModel = getSelectionModel();
ArrayList<IContentPart<? extends Node>> currentSelection = new ArrayList<>(
selectionModel.getSelectionUnmodifiable());
if (!currentSelection.equals(initialSelection)) {
selectionModel.setSelection(initialSelection);
}
return Status.OK_STATUS;
}
private boolean checkMessages(String... expectedMessages) {
ArrayList<String> messages = findElements(By.cssSelector("#messages p"))
.stream().map(WebElement::getText)
.map(text -> text.replaceFirst("Value: ", ""))
.collect(Collectors.toCollection(ArrayList::new));
return messages
.equals(new ArrayList<String>(Arrays.asList(expectedMessages)));
}
public synchronized boolean changedWorldBeliefState() {
ArrayList<Object> temp1= new ArrayList<Object>();
ArrayList<Object> temp2= new ArrayList<Object>();
temp1.addAll(listOfWorldBeliefStates);
temp2.addAll(listOfPreviousWorldBeliefStates);
return (!temp1.equals(temp2));
}
/**
* For the root switch, searches all the target nodes reachable in the base
* graph, and compares paths to the ones in the comp graph.
*
* @param base the graph that is indexed for all reachable target nodes
* from the root node
* @param comp the graph that the base graph is compared to
* @param rootSw both ecmp graphs are calculated for the root node
* @return all the routes that have changed in the base graph
*/
private Set<ArrayList<DeviceId>> compareGraphs(EcmpShortestPathGraph base,
EcmpShortestPathGraph comp,
DeviceId rootSw) {
ImmutableSet.Builder<ArrayList<DeviceId>> changedRoutesBuilder =
ImmutableSet.builder();
HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> baseMap =
base.getAllLearnedSwitchesAndVia();
HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> compMap =
comp.getAllLearnedSwitchesAndVia();
for (Integer itrIdx : baseMap.keySet()) {
HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> baseViaMap =
baseMap.get(itrIdx);
for (DeviceId targetSw : baseViaMap.keySet()) {
ArrayList<ArrayList<DeviceId>> basePath = baseViaMap.get(targetSw);
ArrayList<ArrayList<DeviceId>> compPath = getVia(compMap, targetSw);
if ((compPath == null) || !basePath.equals(compPath)) {
log.trace("Impacted route:{} -> {}", targetSw, rootSw);
ArrayList<DeviceId> route = new ArrayList<>();
route.add(targetSw); // switch with rules to populate
route.add(rootSw); // towards this destination
changedRoutesBuilder.add(route);
}
}
}
return changedRoutesBuilder.build();
}
public boolean equals(BusinessValueList other) {
/*
* list compare is broken if using hibernate.
*/
ArrayList<IPenaltyDefinition> aux = new ArrayList<IPenaltyDefinition>(getPenalties());
boolean result = importance == other.getImportance() &&
aux.equals(other.getPenalties());
return result;
}
private boolean saveOwnServersToTomlList() {
if (dnscrypt_proxy_toml == null) {
return false;
}
ArrayList<String> newLines = new ArrayList<>();
newLines.add("[static]");
for (DNSServerItem dnsServerItem: list_dns_servers) {
if (dnsServerItem.getOwnServer()) {
newLines.add("[static.'" + dnsServerItem.getName() + "']");
newLines.add("stamp = 'sdns:" + dnsServerItem.getSDNS() + "'");
}
}
ArrayList<String> oldLines = new ArrayList<>();
boolean lockStatic = false;
for (int i = 0; i < dnscrypt_proxy_toml.size(); i++) {
String line = dnscrypt_proxy_toml.get(i);
if (line.contains("[static]")) {
lockStatic = true;
oldLines.add(line);
} else if (line.contains("[") && line.contains("]") && !line.contains("static") && lockStatic) {
lockStatic = false;
} else if (lockStatic){
oldLines.add(line);
}
}
if (newLines.equals(oldLines)) {
return false;
}
dnscrypt_proxy_toml.removeAll(oldLines);
dnscrypt_proxy_toml.addAll(newLines);
return true;
}
private static <T> boolean equals(final ArrayList<T> a, final ArrayList<T> b) {
if (null == a) {
return null == b;
}
return a.equals(b);
}
private static <T> boolean equals(final ArrayList<T> a, final ArrayList<T> b) {
if (null == a) {
return null == b;
}
return a.equals(b);
}
public boolean isModified(ApplicationSettings settings) {
final ArrayList<Alias> aliases = new ArrayList<>();
obtainAliases(aliases, settings);
return !aliases.equals(myAliases);
}