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:Main.java

private static String assertArchiveEquality(List<String> expected, List<String> archived) {
    String compare = compareFileLists(expected, archived);
    if (!(expected.size() == archived.size()))
        return "Not the same number of current files\n" + compare;
    if (!expected.equals(archived))
        return "Different backup files, but same amount\n" + compare;
    return null;// ww w . j a v a  2 s. c  o  m
}

From source file:com.palantir.ptoss.cinch.swing.JListWiringHarness.java

private static void updateListModel(JList list, List<?> newContents) {
    if (newContents == null) {
        newContents = ImmutableList.of();
    }/*www  .  j  a va2s .c om*/
    ListModel oldModel = list.getModel();
    List<Object> old = Lists.newArrayListWithExpectedSize(oldModel.getSize());
    for (int i = 0; i < oldModel.getSize(); i++) {
        old.add(oldModel.getElementAt(i));
    }
    if (old.equals(newContents)) {
        return;
    }
    Object[] selected = list.getSelectedValues();
    DefaultListModel listModel = new DefaultListModel();
    for (Object obj : newContents) {
        listModel.addElement(obj);
    }
    list.setModel(listModel);
    List<Integer> newIndices = Lists.newArrayListWithCapacity(selected.length);
    Set<Object> selectedSet = Sets.newHashSet(selected);
    for (int i = 0; i < listModel.size(); i++) {
        if (selectedSet.contains(listModel.elementAt(i))) {
            newIndices.add(i);
        }
    }
    list.setSelectedIndices(ArrayUtils.toPrimitive(newIndices.toArray(new Integer[0])));
}

From source file:io.jenkins.blueocean.config.JenkinsJSExtensions.java

private static void refreshCacheIfNeeded() {
    List<PluginWrapper> latestPlugins = Jenkins.getInstance().getPluginManager().getPlugins();
    if (!latestPlugins.equals(pluginCache)) {
        refreshCache(latestPlugins);/*from   w  ww .j a v  a 2  s .com*/
    }
}

From source file:io.jenkins.blueocean.config.JenkinsJSExtensions.java

private synchronized static void refreshCache(List<PluginWrapper> latestPlugins) {
    if (!latestPlugins.equals(pluginCache)) {
        pluginCache.clear();//  w w  w.j av  a 2s . c o  m
        pluginCache.addAll(latestPlugins);
        refreshCache(pluginCache);
    }
    for (PluginWrapper pluginWrapper : pluginCache) {
        //skip if not active
        if (!pluginWrapper.isActive()) {
            continue;
        }
        //skip probing plugin if already read
        if (jsExtensionCache.get(pluginWrapper.getLongName()) != null) {
            continue;
        }
        try {
            Enumeration<URL> dataResources = pluginWrapper.classLoader
                    .getResources("jenkins-js-extension.json");
            boolean hasDefinedExtensions = false;

            while (dataResources.hasMoreElements()) {
                URL dataRes = dataResources.nextElement();

                LOGGER.debug("Reading 'jenkins-js-extension.json' from '{}'.", dataRes);

                try (InputStream dataResStream = dataRes.openStream()) {
                    Map<String, Object> extensionData = mapper.readValue(dataResStream, Map.class);

                    String pluginId = getGav(extensionData);
                    if (pluginId != null) {
                        // Skip if the plugin name specified on the extension data does not match the name
                        // on the PluginWrapper for this iteration. This can happen for e.g. aggregator
                        // plugins, in which case you'll be seeing extension resources on it's dependencies.
                        // We can skip these here because we will process those plugins themselves in a
                        // future/past iteration of this loop.
                        if (!pluginId.equals(pluginWrapper.getShortName())) {
                            continue;
                        }
                    } else {
                        LOGGER.error(String.format("Plugin %s JS extension has missing hpiPluginId",
                                pluginWrapper.getLongName()));
                        continue;
                    }

                    List<Map> extensions = (List<Map>) extensionData.get(PLUGIN_EXT);
                    if (extensions != null) {
                        for (Map extension : extensions) {
                            try {
                                String type = (String) extension.get("type");
                                if (type != null) {
                                    BlueExtensionClassContainer extensionClassContainer = Jenkins.getInstance()
                                            .getExtensionList(BlueExtensionClassContainer.class).get(0);
                                    Map classInfo = (Map) mergeObjects(extensionClassContainer.get(type));
                                    List classInfoClasses = (List) classInfo.get("_classes");
                                    classInfoClasses.add(0, type);
                                    extension.put("_class", type);
                                    extension.put("_classes", classInfoClasses);
                                }
                            } catch (Exception e) {
                                LOGGER.error(
                                        "An error occurred when attempting to read type information from jenkins-js-extension.json from: "
                                                + dataRes,
                                        e);
                            }
                        }
                    }

                    extensionData.put(PLUGIN_VER, pluginWrapper.getVersion());
                    jsExtensionCache.put(pluginId, mergeObjects(extensionData));
                    hasDefinedExtensions = true;
                }
            }

            if (!hasDefinedExtensions) {
                // Manufacture an entry for all plugins that do not have any defined
                // extensions. This adds some info about the plugin that the UI might
                // need access to e.g. the plugin version.
                Map<String, Object> extensionData = new LinkedHashMap<>();
                extensionData.put(PLUGIN_ID, pluginWrapper.getShortName());
                extensionData.put(PLUGIN_VER, pluginWrapper.getVersion());
                extensionData.put(PLUGIN_EXT, Collections.emptyList());
                jsExtensionCache.put(pluginWrapper.getShortName(), mergeObjects(extensionData));
            }
        } catch (IOException e) {
            LOGGER.error(String.format("Error locating jenkins-js-extension.json for plugin %s",
                    pluginWrapper.getLongName()));
        }
    }
}

From source file:Main.java

/**
 * Returns <code>true</code> if both lists are the same?
 *
 * @param list1// w  w  w .  j  a v a2  s .c  om
 * @param list2
 * @return
 */
@SuppressWarnings("ObjectEquality")
public static boolean same(final List list1, final List list2) {

    if (list1 == null || list2 == null) {
        return false;
    }
    if (list1.size() != list2.size()) {
        return false;
    }
    if (list1 == list2) {
        return true;
    }
    if (list1.equals(list2)) {
        return true;
    }
    for (int i = 0; i < list1.size(); i++) {
        if (!list1.get(i).equals(list2.get(i))) {
            return false;
        }
    }
    return true;
}

From source file:org.apache.hadoop.hive.ql.io.orc.RecordReaderFactory.java

private static boolean checkAcidSchema(List<OrcProto.Type> fileSchema) {
    if (fileSchema.get(0).getKind().equals(OrcProto.Type.Kind.STRUCT)) {
        List<String> acidFields = getAcidEventFields();
        List<String> rootFields = fileSchema.get(0).getFieldNamesList();
        if (acidFields.equals(rootFields)) {
            return true;
        }//from   ww  w  .  j a  va 2s .c  om
    }
    return false;
}

From source file:org.wso2.carbon.identity.relyingparty.saml.IssuerCertificateUtil.java

/**
 * Performs the black list check/*from www .  j av  a2 s . c  o  m*/
 * 
 * @param blackList Array of Lists. One Array element contains the Issuer's cert DN
 * @param cert
 * @return
 * @throws RelyingPartyException
 */
public static boolean isBlackListed(List[] blackList, X509Certificate cert) throws RelyingPartyException {

    if (cert == null) {
        throw new RelyingPartyException("noCertInToken");
    }

    if (blackList != null && blackList.length > 0) {
        List certDN = getDNOfIssuer(cert.getIssuerDN().getName());
        for (int i = 0; i < blackList.length; i++) {
            List issuerDN = blackList[i];
            if (certDN.equals(issuerDN)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.wso2.carbon.identity.relyingparty.saml.IssuerCertificateUtil.java

/**
 * Do a white list check//ww w .  jav a  2s  .  c  o  m
 * 
 * @param whiteList Array of Lists. One Array element contains the Issuer's cert DN
 * @param cert
 * @return
 * @throws RelyingPartyException
 */
public static boolean isWhiteListed(List[] whiteList, X509Certificate cert) throws RelyingPartyException {

    if (cert == null) {
        throw new RelyingPartyException("noCertInToken");
    }

    if (whiteList != null && whiteList.length > 0) {
        List certDN = getDNOfIssuer(cert.getIssuerDN().getName());
        for (int i = 0; i < whiteList.length; i++) {
            List issuerDN = whiteList[i];
            if (certDN.equals(issuerDN)) {
                return true;
            }
        }
    }
    return false;
}

From source file:Alias2.java

public static void verify(List output, List expected) {
    verifyLength(output.size(), expected.size(), Test.EXACT);
    if (!expected.equals(output)) {
        //find the line of mismatch
        ListIterator it1 = expected.listIterator();
        ListIterator it2 = output.listIterator();
        while (it1.hasNext() && it2.hasNext() && it1.next().equals(it2.next()))
            ;//from   ww  w  . j a  v a 2  s.c  o m
        throw new LineMismatchException(it1.nextIndex(), it1.previous().toString(), it2.previous().toString());
    }
}

From source file:com.snp.site.init.SystemInit.java

public static String getStoredPassword(String useranme) {
    try {/*from   w  ww . ja v  a2 s. c  o  m*/
        AdvanceDAO adao = (AdvanceDAO) ApplicationContextFactory.getFileAppContext().getBean("advanceDAO");
        String sql = "select o from com.snp.site.model.SiteUser o where o.username='" + useranme + "'";
        List ls = adao.find(sql);
        if (ls.equals(null) || ls.size() == 0) {
            return null;
        }
        SiteUser siteUser = (SiteUser) ls.get(0);
        return siteUser.getPassword();
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}