Example usage for java.util List equals

List of usage examples for java.util List equals

Introduction

In this page you can find the example usage for java.util List equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this list for equality.

Usage

From source file:org.jahia.services.content.rules.Service.java

public void updateDependencies(AddedNodeFact node) throws RepositoryException {
    JahiaTemplatesPackage pack = ServicesRegistry.getInstance().getJahiaTemplateManagerService()
            .getTemplatePackageRegistry()
            .lookupByIdAndVersion(node.getNode().getParent().getName(), new ModuleVersion(node.getName()));
    if (pack != null) {
        Value[] dependencies = node.getNode().getProperty("j:dependencies").getValues();
        List<String> depends = new ArrayList<String>();
        for (Value dependency : dependencies) {
            depends.add(dependency.getString());
        }//w w w. jav a 2 s .  c om
        if (!depends.equals(pack.getDepends())) {
            ServicesRegistry.getInstance().getJahiaTemplateManagerService().updateDependencies(pack, depends);
            //                ServicesRegistry.getInstance().getJahiaTemplateManagerService().regenerateManifest(pack, node.getNode().getSession());
        }
    }
}

From source file:org.haedus.datatypes.phonetic.FeatureModel.java

private String getBestDiacritic(List<Double> featureArray, List<Double> bestFeatures, double lastMinimum) {
    String bestDiacritic = "";
    double minimumDifference = lastMinimum;
    List<Double> bestCompiled = new ArrayList<Double>();

    for (Map.Entry<String, List<Double>> entry : diacritics.entrySet()) {
        List<Double> diacriticFeatures = entry.getValue();
        List<Double> compiledFeatures = new ArrayList<Double>();
        if (diacriticFeatures.size() == bestFeatures.size()) {
            for (int i = 0; i < diacriticFeatures.size(); i++) {
                Double left = diacriticFeatures.get(i);
                Double right = bestFeatures.get(i);

                if (left.isNaN()) {
                    compiledFeatures.add(right);
                } else {
                    compiledFeatures.add(left);
                }/*from   w ww.j  av a2  s.co  m*/
            }
        } else {
            LOGGER.error("Difference in array sizes: {} vs  {}", diacriticFeatures, bestFeatures);
        }

        if (!compiledFeatures.equals(bestFeatures)) {
            double difference = getDifferenceValue(compiledFeatures, featureArray);
            if (difference < minimumDifference) {
                minimumDifference = difference;
                bestDiacritic = entry.getKey();
                bestCompiled = compiledFeatures;
            } else if (difference == minimumDifference) {
                // Modify this to use sets
                // TODO: what is this?
            }
        }
    }
    if (minimumDifference > 0 && minimumDifference != lastMinimum) {
        return bestDiacritic + getBestDiacritic(featureArray, bestCompiled, minimumDifference);
    } else {
        return bestDiacritic;
    }
}

From source file:de.ailis.wlandsuite.FixWlOffsets.java

/**
 * @see de.ailis.wlandsuite.cli.CLIProg#run(java.lang.String[])
 */// w w  w. j  a  v  a  2s  .c  o m

@Override
protected void run(String[] params) throws IOException {
    WlExe wl;
    List<Integer> oldOffsets, newOffsets;
    File file;
    int oldOffset, newOffset;
    boolean changed = false;

    // Read wasteland directory parameter
    if (params.length > 1) {
        wrongUsage("Too many parameters");
    }
    if (params.length == 0) {
        wrongUsage("No wasteland directory specified");
    }
    this.wlDir = new File(params[0]).getPath() + File.separatorChar;

    // Open the wl.exe
    wl = new WlExe(new File(this.wlDir + "wl.exe"));
    try {
        // Fix HTDS1 offsets
        file = new File(this.wlDir + "allhtds1");
        if (file.length() > 34307) {
            log.warn("allhtds1 file is larger then 34307 bytes. This can cause trouble");
        }
        oldOffsets = wl.getHtds1Offsets();
        newOffsets = Htds.getMsqOffsets(file);
        if (!oldOffsets.equals(newOffsets)) {
            for (int i = 0; i < oldOffsets.size(); i++) {
                oldOffset = oldOffsets.get(i).intValue();
                newOffset = newOffsets.get(i).intValue();
                if (oldOffset != newOffset) {
                    log.info("Adjusting HTDS1 bank " + i + " offset from " + oldOffset + " to " + newOffset);
                }
                wl.setHtds1Offsets(newOffsets);
                changed = true;
            }
        }

        // Fix HTDS2 offsets
        file = new File(this.wlDir + "allhtds2");
        if (file.length() > 39230) {
            log.warn("allhtds2 file is larger then 39230 bytes. This can cause trouble");
        }
        oldOffsets = wl.getHtds2Offsets();
        newOffsets = Htds.getMsqOffsets(new File(this.wlDir + "allhtds2"));
        if (!oldOffsets.equals(newOffsets)) {
            for (int i = 0; i < oldOffsets.size(); i++) {
                oldOffset = oldOffsets.get(i).intValue();
                newOffset = newOffsets.get(i).intValue();
                if (oldOffset != newOffset) {
                    log.info("Adjusting HTDS2 bank " + i + " offset from " + oldOffset + " to " + newOffset);
                }
                wl.setHtds2Offsets(newOffsets);
                changed = true;
            }
        }

        // Fix PICS1 offsets
        file = new File(this.wlDir + "allpics1");
        if (file.length() > 105866) {
            log.warn("allpics1 file is larger then 105866 bytes. This can cause trouble");
        }
        oldOffsets = wl.getPics1Offsets();
        newOffsets = Pics.getMsqOffsets(file);
        if (!oldOffsets.equals(newOffsets)) {
            for (int i = 0; i < oldOffsets.size(); i++) {
                oldOffset = oldOffsets.get(i).intValue();
                newOffset = newOffsets.get(i).intValue();
                if (oldOffset != newOffset) {
                    log.info("Adjusting PICS1 offset " + i + " from " + oldOffset + " to " + newOffset);
                }
                wl.setPics1Offsets(newOffsets);
                changed = true;
            }
        }

        // Fix PICS2 offsets
        file = new File(this.wlDir + "allpics2");
        oldOffsets = wl.getPics2Offsets();
        newOffsets = Pics.getMsqOffsets(file);
        if (!oldOffsets.equals(newOffsets)) {
            for (int i = 0; i < oldOffsets.size(); i++) {
                oldOffset = oldOffsets.get(i).intValue();
                newOffset = newOffsets.get(i).intValue();
                if (oldOffset != newOffset) {
                    log.info("Adjusting PICS2 offset " + i + " from " + oldOffset + " to " + newOffset);
                }
                wl.setPics2Offsets(newOffsets);
                changed = true;
            }
        }
    } finally {
        wl.close();
    }

    if (!changed) {
        log.info("No offsets need to be fixed");
    }
}

From source file:com.github.abrarsyed.gmcp.patching.ContextualPatch.java

private boolean patchCreatesNewFileThatAlreadyExists(SinglePatch patch, List<String> originalFile)
        throws PatchException {
    if (patch.hunks.length != 1) {
        return false;
    }/*from   ww w. j  av  a 2  s. c  o m*/
    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<String>(hunk.modifiedCount);
    applyHunk(target, hunk);
    return target.equals(originalFile);
}

From source file:de.unioninvestment.eai.portal.portlet.crud.domain.model.AbstractDataContainer.java

public void replaceFilters(List<Filter> newFilters, boolean removeDurable, boolean forceReplace) {
    List<Filter> replacementFilters = newFilters;
    if (!removeDurable) {
        replacementFilters = collectDurableFilters(filterList);
        replacementFilters.addAll(newFilters);
    }/* w w w .  ja  v  a 2 s .co m*/
    if (forceReplace || !replacementFilters.equals(filterList)) {
        if (shouldFilterNothing(replacementFilters)) {
            replaceVaadinFilters(asList((Filter) new Nothing()));
        } else {
            try {
                replaceVaadinFilters(replacementFilters);
            } catch (RuntimeException e) {
                if (e.getCause() instanceof SQLTimeoutException) {
                    applyNothingFilter(removeDurable);
                    throw new BusinessException("portlet.crud.warn.searchQueryTimeout");
                } else {
                    throw e;
                }
            }
        }
        filterList = replacementFilters;
    }
}

From source file:jk_5.nailed.mcp.patching.ContextualPatch.java

private boolean patchCreatesNewFileThatAlreadyExists(SinglePatch patch, List<String> originalFile)
        throws PatchException {
    if (patch.hunks.length != 1) {
        return false;
    }//from   w  w w  . ja va 2s  .c  o m
    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<String>(hunk.modifiedCount);
    applyHunk(target, hunk, 0);
    return target.equals(originalFile);
}

From source file:dk.statsbiblioteket.doms.surveillance.surveyor.WebServiceSurveyor.java

/**
 * Set configuration./*from  w  w  w .java2  s.  c  om*/
 *
 * This method will read the configuration values, and do initialization
 * based on this.
 *
 * @see #REST_URLS_CONFIGURATION_PARAMETER
 * @see #SOAP_URLS_CONFIGURATION_PARAMETER
 * @see #IGNOREFILE_CONFIGURATION_PARAMETER
 */
private synchronized void readConfiguration() {
    log.trace("Enter readConfiguration()");

    //Read configuration
    String restUrlParameter = ConfigCollection.getProperties().getProperty(REST_URLS_CONFIGURATION_PARAMETER);
    String soapUrlParameter = ConfigCollection.getProperties().getProperty(SOAP_URLS_CONFIGURATION_PARAMETER);
    String ignoredMessagesPath = ConfigCollection.getProperties()
            .getProperty(IGNOREFILE_CONFIGURATION_PARAMETER);
    List<String> restStatusUrls;
    List<String> soapStatusUrls;
    File ignoredMessagesFile;

    //Initialize REST status urls
    if (restUrlParameter == null || restUrlParameter.equals("")) {
        restStatusUrls = Collections.emptyList();
    } else {
        String[] splits = restUrlParameter.split(";");
        restStatusUrls = new ArrayList<String>();
        for (String split : splits) {
            if (split != null && !split.isEmpty()) {
                restStatusUrls.add(split);
            }
        }
    }
    if (!restStatusUrls.equals(this.restStatusUrls)) {
        log.info("Setting list of surveyed REST status URLs to '" + restStatusUrls + "'");
        this.restStatusUrls = restStatusUrls;
    }

    //Initialize SOAP status urls
    if (soapUrlParameter == null || soapUrlParameter.equals("")) {
        soapStatusUrls = Collections.emptyList();
    } else {
        soapStatusUrls = Arrays.asList(soapUrlParameter.split(";"));
    }
    if (!soapStatusUrls.equals(this.soapStatusUrls)) {
        log.info("Setting list of surveyed SOAP status URLs to '" + soapStatusUrls + "'");
        this.soapStatusUrls = soapStatusUrls;
    }

    //Initialize file with list of ignored messages.
    if (ignoredMessagesPath == null || ignoredMessagesPath.equals("")) {
        ignoredMessagesPath = DEFAULT_IGNORED_MESSAGES_PATH;
    }
    ignoredMessagesFile = new File(ignoredMessagesPath);
    if (!ignoredMessagesFile.getAbsoluteFile().getParentFile().isDirectory()
            || (ignoredMessagesFile.exists() && !ignoredMessagesFile.isFile())) {
        log.warn("Configuration for file of ignored messages '" + ignoredMessagesPath
                + "' does not denote a valid file." + " Falling back to default.");
        ignoredMessagesPath = DEFAULT_IGNORED_MESSAGES_PATH;
        ignoredMessagesFile = new File(ignoredMessagesPath);
    }
    if (!this.ignoredMessagesFile.equals(ignoredMessagesFile)) {
        log.info("Setting file with list of ignored messages to '" + ignoredMessagesFile + "'");
        this.ignoredMessagesFile = ignoredMessagesFile;
        readIgnoredMessagesFromFile();
    }
}

From source file:com.pentaho.qa.gui.web.puc.BasePage.java

protected boolean isSorted(List<String> actualList, Sort sort) {
    List<String> tmp = new ArrayList<String>(actualList);
    Collections.sort(tmp);/*from   w w w  .j a  v  a 2s .  c  o m*/
    if (sort == Sort.DESC) {
        Collections.reverse(tmp);
    }
    return tmp.equals(actualList);
}

From source file:org.apache.ambari.server.controller.ganglia.GangliaPropertyProviderTest.java

private boolean isUrlParamsEquals(URIBuilder actualUri, URIBuilder expectedUri) {
    for (final NameValuePair expectedParam : expectedUri.getQueryParams()) {
        NameValuePair actualParam = (NameValuePair) CollectionUtils.find(actualUri.getQueryParams(),
                new Predicate() {

                    @Override/* w w  w  . j  a v a 2  s  . c om*/
                    public boolean evaluate(Object arg0) {
                        if (!(arg0 instanceof NameValuePair))
                            return false;

                        NameValuePair otherObj = (NameValuePair) arg0;
                        return otherObj.getName().equals(expectedParam.getName());
                    }
                });

        List<String> actualParamList = new ArrayList<String>(Arrays.asList(actualParam.getValue().split(",")));
        List<String> expectedParamList = new ArrayList<String>(
                Arrays.asList(expectedParam.getValue().split(",")));

        Collections.sort(actualParamList);
        Collections.sort(expectedParamList);

        if (!actualParamList.equals(expectedParamList))
            return false;
    }

    return true;
}

From source file:squash.booking.lambdas.core.OptimisticPersisterTest.java

@Test
public void testGetAllItemsCorrectlyCallsSimpleDB() throws Exception {

    // ARRANGE//from  w  ww .j a  va  2 s.  com
    initialiseOptimisticPersister();

    SelectRequest selectRequest = new SelectRequest();
    selectRequest.setConsistentRead(true);
    selectRequest.setSelectExpression("select * from `" + testSimpleDBDomainName + "`");

    // Configure select result with an item to be returned:
    SelectResult selectResult = new SelectResult();
    Set<Item> items = new HashSet<>();
    Item item = new Item();
    String itemDate = "2016-07-23";
    item.setName(itemDate);
    item.setAttributes(allAttributes);
    items.add(item);
    selectResult.setItems(items);
    mockery.checking(new Expectations() {
        {
            oneOf(mockSimpleDBClient).select(with(equal(selectRequest)));
            will(returnValue(selectResult));
        }
    });

    List<ImmutablePair<String, List<Attribute>>> expectedItems = new ArrayList<>();
    ImmutablePair<String, List<Attribute>> pair = new ImmutablePair<>(itemDate,
            new ArrayList<>(activeNonVersionAttributes));
    expectedItems.add(pair);

    // ACT
    List<ImmutablePair<String, List<Attribute>>> actualItems = optimisticPersister.getAllItems();

    // ASSERT
    assertTrue("OptimisticPersister should return the correct items. Actual: " + actualItems + ", Expected: "
            + expectedItems, actualItems.equals(expectedItems));
}