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

The following examples show how to use java.util.ArrayList#equals() . 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 check out the related API usage on the sidebar.
Example 1
Source File: PreferencesDNSCryptServers.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
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 File: GPUKernalFuncTranspiler.java    From Concurnas with 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 File: DOMOutputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 4
Source File: SampleListInput.java    From jaamsim with 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
Source File: Collect.java    From crate with 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 6
Source File: DOMOutputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 7
Source File: BusinessValueList.java    From SeaCloudsPlatform with Apache License 2.0 5 votes vote down vote up
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 8
Source File: DefaultRoutingHandler.java    From onos with 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 9
Source File: Behavior.java    From cst with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 10
Source File: AbstractDebounceSynchronizeIT.java    From flow with Apache License 2.0 5 votes vote down vote up
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 11
Source File: ChangeSelectionOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@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 12
Source File: ChangeSelectionOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@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 13
Source File: SectionRecyclerCellManager.java    From Shield with 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 14
Source File: TableColumnsGeometryPersisterImpl.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
private void doPersistColumnsConfig(ArrayList<Pair<Integer, Integer>> columnsConfig) {
	if (columnsConfig.equals(prevColumnsConfig)) {
		return;
	}
	prevColumnsConfig = columnsConfig;
	configPairs.put(keyId, columnsConfig);
}
 
Example 15
Source File: ScopeAndTypeTests.java    From Concurnas with 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 16
Source File: Navigator.java    From Wurst7 with 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 17
Source File: WordProperty.java    From AOSP-Kayboard-7.1.2 with 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 18
Source File: WordProperty.java    From Indic-Keyboard with 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 19
Source File: PreferencesDNSCryptServers.java    From InviZible with GNU General Public License v3.0 4 votes vote down vote up
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 20
Source File: AliasTable.java    From MavenHelper with 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);
}