Java Code Examples for java.util.ArrayList#equals()

The following examples show how to use java.util.ArrayList#equals() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
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");

}
 
Example 2
Source Project: Concurnas   File: GPUKernalFuncTranspiler.java    License: MIT License 6 votes vote down vote up
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;
}
 
Example 3
Source Project: crate   File: Collect.java    License: Apache License 2.0 6 votes vote down vote up
@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)
    );
}
 
Example 4
Source Project: jaamsim   File: SampleListInput.java    License: Apache License 2.0 6 votes vote down vote up
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));
		}
	}
 
Example 5
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;
}
 
Example 6
Source Project: Wurst7   File: Navigator.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void copyNavigatorList(ArrayList<Feature> list)
{
	if(list.equals(navigatorList))
		return;
	
	list.clear();
	list.addAll(navigatorList);
}
 
Example 7
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();
}
 
Example 8
Source Project: Concurnas   File: ScopeAndTypeTests.java    License: MIT License 5 votes vote down vote up
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();
	}
}
 
Example 9
private void doPersistColumnsConfig(ArrayList<Pair<Integer, Integer>> columnsConfig) {
	if (columnsConfig.equals(prevColumnsConfig)) {
		return;
	}
	prevColumnsConfig = columnsConfig;
	configPairs.put(keyId, columnsConfig);
}
 
Example 10
Source Project: Shield   File: SectionRecyclerCellManager.java    License: MIT License 5 votes vote down vote up
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);
        }
    }
}
 
Example 11
@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;
}
 
Example 12
@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;
}
 
Example 13
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)));
}
 
Example 14
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));
}
 
Example 15
Source Project: onos   File: DefaultRoutingHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 16
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;
}
 
Example 17
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;
}
 
Example 18
private static <T> boolean equals(final ArrayList<T> a, final ArrayList<T> b) {
    if (null == a) {
        return null == b;
    }
    return a.equals(b);
}
 
Example 19
Source Project: Indic-Keyboard   File: WordProperty.java    License: Apache License 2.0 4 votes vote down vote up
private static <T> boolean equals(final ArrayList<T> a, final ArrayList<T> b) {
    if (null == a) {
        return null == b;
    }
    return a.equals(b);
}
 
Example 20
Source Project: MavenHelper   File: AliasTable.java    License: Apache License 2.0 4 votes vote down vote up
public boolean isModified(ApplicationSettings settings) {
	final ArrayList<Alias> aliases = new ArrayList<>();
	obtainAliases(aliases, settings);
	return !aliases.equals(myAliases);
}