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:net.kamhon.ieagle.struts2.JTextProviderSupport.java

/**
 * Get a text from the resource bundles associated with this action. The resource bundles are searched, starting
 * with the one associated with this particular action, and testing all its superclasses' bundles. It will stop once
 * a bundle is found that contains the given text. This gives a cascading style that allow global texts to be
 * defined for an application base class. If no text is found for this text name, the default value is returned.
 * //from w w w .ja  va 2 s .  co m
 * @param key
 *            name of text to be found
 * @param defaultValue
 *            the default value which will be returned if no text is found
 * @param args
 *            a List of args to be used in a MessageFormat message
 * @return value of named text
 */
public String getText(String key, String defaultValue, List<?> args) {
    Object[] argsArray = ((args != null && !args.equals(Collections.emptyList())) ? args.toArray() : null);
    String text = languageFrameworkService.getText(key, getLocale(), argsArray);
    if (text != null && !key.equals(text)) {
        return text;
    } else if (clazz != null) {
        return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, argsArray);
    } else {
        return LocalizedTextUtil.findText(bundle, key, getLocale(), defaultValue, argsArray);
    }
}

From source file:EnhancedSpinnerListFormatter.java

/**
 * Changes the list that defines this sequence and resets the index
 * of the models <code>value</code> to zero.  Note that <code>list</code>
 * is not copied, the model just stores a reference to it.
 * <p/>//from  w w  w . j  a v  a2 s.  c  o m
 * This method fires a <code>ChangeEvent</code> if <code>list</code> is
 * not equal to the current list.
 *
 * @param list the sequence that this model represents
 * @throws IllegalArgumentException if <code>list</code> is
 *                                  <code>null</code> or zero length
 * @see #getList
 */
public void setList(List<?> list) {
    if ((list == null) || (list.size() == 0)) {
        throw new IllegalArgumentException("invalid list");
    }
    if (!list.equals(this.list)) {
        this.list = list;
        index = 0;
        fireStateChanged();
    }
}

From source file:it.unibas.spicy.model.mapping.rewriting.operators.GenerateExpansionMoreCompactOrder.java

private boolean contains(List<List<ExpansionElement>> examinedPermutations,
        List<ExpansionElement> permutation) {
    for (List<ExpansionElement> examinedPermutation : examinedPermutations) {
        //            if (equals(examinedPermutation, permutation)) {
        if (examinedPermutation.equals(permutation)) {
            return true;
        }/*from w ww.  j a  v  a2 s. co  m*/
    }
    return false;
}

From source file:com.vmware.identity.saml.config.Config.java

/**
 *
 * Creates a new configuration//from w w  w  .  j  a va2  s  .co m
 *
 * @param samlAuthorityConfig
 *           Saml authority configuration properties, required
 * @param tokenRestrictions
 *           token issuance configuration properties, required
 * @param validCerts
 *           not empty array of SAML authority certificates, required. No
 *           assumptions should be made for the order of the certificate
 *           chains. However, within certificate chains, the certificates are
 *           ordered from leaf to root CA. Entire chains can be kept even if
 *           some of them is no longer valid, because when certificate is
 *           checked if it is signed with a certificate among those chains,
 *           this certificate will be no longer valid itself. required
 * @param clockTolerance
 *           Maximum allowed clock skew between token sender and consumer, in
 *           milliseconds, required.
 * @param inExternalIdps a list of external idps registered.
 * @throws IllegalArgumentException
 *            when some of the arguments are invalid
 */
public Config(SamlAuthorityConfiguration samlAuthorityConfig, TokenRestrictions tokenRestrictions,
        Collection<List<Certificate>> validCerts, long clockTolerance, Collection<IDPConfig> inExternalIdps) {

    Validate.notNull(samlAuthorityConfig);
    Validate.notNull(tokenRestrictions);
    Validate.notEmpty(validCerts);

    List<Certificate> authorityCert = samlAuthorityConfig.getSigningCertificateChain();
    boolean authorityCertInValidCerts = false;

    for (List<Certificate> currentChain : validCerts) {
        Validate.notEmpty(currentChain);
        Validate.noNullElements(currentChain);
        if (!authorityCertInValidCerts && currentChain.equals(authorityCert)) {
            authorityCertInValidCerts = true;
        }
    }
    Validate.isTrue(authorityCertInValidCerts, "signing certificate chain is not in valid chains.");
    Validate.isTrue(clockTolerance >= 0);

    this.samlAuthorityConfig = samlAuthorityConfig;
    this.validCerts = validCerts;
    this.clockTolerance = clockTolerance;
    this.tokenRestrictions = tokenRestrictions;
    HashMap<String, IDPConfig> idpsSet = new HashMap<String, IDPConfig>();
    if (inExternalIdps != null) {
        for (IDPConfig conf : inExternalIdps) {
            if (conf != null) {
                idpsSet.put(conf.getEntityID(), conf);
            }
        }
    }
    this.externalIdps = Collections.unmodifiableMap(idpsSet);
}

From source file:org.wso2.carbon.identity.openidconnect.model.RequestObject.java

private void populateRequestedClaimValues(List<RequestedClaim> requestedClaims,
        JSONObject jsonObjectClaimAttributes, String claimName, String claimType) {

    RequestedClaim claim = new RequestedClaim();
    claim.setName(claimName);//from www .  j  av  a2 s  .  c o  m
    claim.setType(claimType);
    if (jsonObjectClaimAttributes != null) {

        //To iterate claim attributes object to fetch the attribute key and value for the fetched
        // requested claim in the fetched claim requester
        for (Map.Entry<String, Object> claimAttributes : jsonObjectClaimAttributes.entrySet()) {
            if (jsonObjectClaimAttributes.get(claimAttributes.getKey()) != null) {
                Object value = jsonObjectClaimAttributes.get(claimAttributes.getKey());
                if (ESSENTIAL.equals(claimAttributes.getKey())) {
                    claim.setEssential((Boolean) value);
                } else if (VALUE.equals(claimAttributes.getKey())) {
                    claim.setValue((String) value);
                } else if (VALUES.equals(claimAttributes.getKey())) {
                    JSONArray jsonArray = (JSONArray) value;
                    if (jsonArray != null && jsonArray.size() > 0) {
                        List<String> values = new ArrayList<>();
                        for (Object aJsonArray : jsonArray) {
                            values.add(aJsonArray.toString());
                        }
                        claim.setValues(values);
                    }
                }
            }
            requestedClaims.add(claim);
        }
    } else {
        requestedClaims.add(claim);
    }
}

From source file:org.jasig.ssp.service.security.oauth2.impl.OAuth2ClientServiceImpl.java

private boolean areMatching(List<PersistentGrantedAuthority> auth1, List<PersistentGrantedAuthority> auth2) {
    if (auth1 == auth2) {
        return true;
    }/*  w  w w .j a v  a 2  s . co  m*/
    if (auth1 == null || auth2 == null) {
        return false;
    }
    return auth1.equals(auth2);
}

From source file:org.apache.hadoop.hbase.master.AssignmentPlan.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }//  www  .ja va2  s . c o  m
    if (o == null) {
        return false;
    }
    if (getClass() != o.getClass()) {
        return false;
    }
    // To compare the map from objec o is identical to current assignment map.
    Map<HRegionInfo, List<HServerAddress>> comparedMap = ((AssignmentPlan) o).getAssignmentMap();

    // compare the size
    if (comparedMap.size() != this.assignmentMap.size())
        return false;

    // compare each element in the assignment map
    for (Map.Entry<HRegionInfo, List<HServerAddress>> entry : comparedMap.entrySet()) {
        List<HServerAddress> serverList = this.assignmentMap.get(entry.getKey());
        if (serverList == null && entry.getValue() != null) {
            return false;
        } else if (!serverList.equals(entry.getValue())) {
            return false;
        }
    }
    return true;
}

From source file:org.opensingular.form.wicket.SValidationFeedbackHandler.java

protected void updateValidationMessages(AjaxRequestTarget target, Collection<IValidationError> newErrors) {
    List<IValidationError> oldErrors = new ArrayList<>(currentErrors);

    this.currentErrors.clear();
    this.currentErrors.addAll(newErrors);

    if (!oldErrors.equals(newErrors)) {
        fireFeedbackChanged(target, this.feedbackFence.getMainContainer(),
                resolveRootInstances(this.feedbackFence.getMainContainer()), oldErrors, newErrors);
    }//w w  w .j  a va2  s . c  o m
}

From source file:org.apache.storm.verify.VerifyUtils.java

public static void verifyCassandra(String cassandraUrl, String keyspaceName, String columnFamily,
        final Map<String, Class> columnNamesToTypes, List<String> expectedRows) throws Exception {
    ColumnFamily<String, String> CF_STANDARD1 = ColumnFamily.newColumnFamily(columnFamily,
            StringSerializer.get(), StringSerializer.get());

    AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder().forCluster("ClusterName")
            .forKeyspace(keyspaceName)/*  ww  w .jav a  2  s .  c  o  m*/
            .withAstyanaxConfiguration(
                    new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
            .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
                    .setMaxConnsPerHost(1).setSeeds(cassandraUrl))
            .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
            .buildKeyspace(ThriftFamilyFactory.getInstance());

    context.start();
    Keyspace keyspace = context.getClient();

    final List<String> actualLines = Lists.newArrayList();
    boolean result = new AllRowsReader.Builder<String, String>(keyspace, CF_STANDARD1).withPageSize(100) // Read 100 rows at a time
            .withConcurrencyLevel(1) // just use one thread.
            .withPartitioner(null) // this will use keyspace's partitioner
            .forEachRow(new Function<Row<String, String>, Boolean>() {
                @Override
                public Boolean apply(@Nullable Row<String, String> row) {
                    ColumnList<String> columns = row.getColumns();
                    String line = "";
                    for (Map.Entry<String, Class> entry : columnNamesToTypes.entrySet()) {
                        String columnName = entry.getKey();
                        line += VerifyUtils.toString(columns.getByteArrayValue(columnName, null),
                                entry.getValue());
                        line += FIELD_SEPERATOR;
                    }
                    actualLines.add(StringUtils.removeEnd(line, FIELD_SEPERATOR));
                    return true;
                }
            }).build().call();

    Collections.sort(actualLines);
    Collections.sort(expectedRows);
    assert actualLines.equals(expectedRows) : "expectedRows = " + expectedRows + " actualRows = " + actualLines;
}

From source file:business.security.DefaultRolesUsersLabs.java

/**
 * Generates default users and labs in the 'dev' and 'test' profiles.
 * Always generates default roles (if not already present).
 *//*from   w w w.  j  a  va 2 s  . c  o  m*/
@PostConstruct
private void initDatabase() {
    log.info("Creating default roles...");
    for (String r : defaultRoles) {
        Role role = roleRepository.findByName(r);
        if (role == null) {
            role = roleRepository.save(new Role(r));
        }
    }

    if (env.acceptsProfiles("prod")) {
        return;
    }

    log.info("Creating default labs...");
    // First, generate default testing labs 100, 102, 104 and 106.
    String[] defaultLabs = new String[] { "AMC, afd. Pathologie",
            "Meander Medisch Centrum, afd. Klinische Pathologie",
            "Canisius-Wilhelmina Ziekenhuis, afd. Pathologie",
            "Laboratorium voor Pathologie (PAL), Dordrecht" };
    Map<Integer, String> cities = new HashMap<>();
    cities.put(100, "Amsterdam");
    cities.put(102, "Amersfoort");
    cities.put(104, "Nijmegen");
    cities.put(106, "Dordrecht");
    int labIdx = 99;
    // Create default labs
    for (String r : defaultLabs) {
        Lab l = labService.findByName(r);
        if (l == null) {
            l = new Lab(new Long(labIdx++), labIdx++, r, null);
            ContactData cd = new ContactData();
            cd.setCity(cities.get(l.getNumber()));
            l.setContactData(cd);
            l = labService.save(l);
        }
        List<String> emailAddresses = new ArrayList<>(Arrays.asList(new String[] {
                getEmailAddress("lab_" + l.getNumber()), getEmailAddress("lab_" + l.getNumber() + "_test") }));
        if (!emailAddresses.equals(l.getEmailAddresses())) {
            log.debug("Updating email addresses for lab " + l.getNumber() + ".");
            l.setEmailAddresses(emailAddresses);
            l = labService.save(l);
        }
    }
    // Second, generate labs in the range 1-99 for testing with large excerpt lists.
    for (int i = 1; i < 100; i++) {
        Lab l = labService.findByNumber(i);
        if (l == null) {
            l = new Lab();
            l.setName("Lab " + i);
            l.setNumber(i);
            ContactData cd = new ContactData();
            cd.setCity("Utrecht");
            l.setContactData(cd);
            l = labService.save(l);
        }
        List<String> emailAddresses = new ArrayList<>(
                Arrays.asList(new String[] { getEmailAddress("lab_" + l.getNumber()), }));
        if (!emailAddresses.equals(l.getEmailAddresses())) {
            log.debug("Updating email addresses for lab " + l.getNumber() + ".");
            l.setEmailAddresses(emailAddresses);
            l = labService.save(l);
        }
    }

    log.info("Creating default users...");
    Lab defaultLab = labService.findByName(defaultLabs[0]);
    // Create default roles and users for each role
    for (String r : defaultRoles) {
        Role role = roleRepository.findByName(r);
        // Create a user for the role if it doesn't exist yet
        String username = getEmailAddress(r);
        User user = userService.findByUsername(username);
        if (user == null) {
            user = createUser(r, role);
            if (role.isHubUser()) {
                Set<Lab> hubLabs = new HashSet<>();
                hubLabs.add(defaultLab);
                hubLabs.add(labService.findByName(defaultLabs[2]));
                user.setHubLabs(hubLabs);
            } else {
                user.setLab(defaultLab);
            }
            user = userService.save(user);
        }
    }
    // Create special requester users
    for (String name : specialRequesters) {
        // Save the role if it doesn't exist yet
        Role role = roleRepository.findByName("requester");
        // Create a user if it doesn't exist yet
        String username = getEmailAddress(name);
        User user = userService.findByUsername(username);
        if (user == null) {
            user = createUser(name, role);
            user.setLab(defaultLab);
            user = userService.save(user);
        }
    }
    // Create default lab users for each lab (if they don't exist)
    for (Lab lab : labService.findAll()) {
        String labNumber = lab.getNumber().toString();
        String username = getEmailAddress("lab_user" + labNumber);

        if (userRepository.findByUsernameAndDeletedFalse(username) == null) {
            Role role = roleRepository.findByName("lab_user");
            User user = createUser("lab_user" + labNumber, role);
            user.setLab(lab);
            user = userRepository.save(user);
        }
    }

    log.info("Created default users and roles.");
}