Example usage for java.util Set equals

List of usage examples for java.util Set equals

Introduction

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

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this set for equality.

Usage

From source file:org.kuali.kfs.module.purap.document.authorization.VendorCreditMemoAccountingLineAuthorizer.java

/**
 * Allow new lines to be rendered at Initiator node
 * @see org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizerBase#renderNewLine(org.kuali.kfs.sys.document.AccountingDocument, java.lang.String)
 *//*www  .j a v a2s.  co  m*/
@Override
public boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty) {
    WorkflowDocument workflowDocument = ((PurchasingAccountsPayableDocument) accountingDocument)
            .getFinancialSystemDocumentHeader().getWorkflowDocument();

    Set<String> currentNodeNames = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentNodeNames)
            && (currentNodeNames.equals(VendorCreditMemoAccountingLineAuthorizer.INITIATOR_NODE)
                    || currentNodeNames.equals(VendorCreditMemoAccountingLineAuthorizer.CONTENT_REVIEW_NODE))) {
        return true;
    }
    return super.renderNewLine(accountingDocument, accountingGroupProperty);
}

From source file:com.github.rwhogg.git_vcr.VelocityReport.java

/**
 * extract the changes between two reviews
 * @return A map of (old) files to changes in results
 *///from  www . ja v  a  2 s .c  o  m
@SuppressWarnings("rawtypes")
private Map<String, Changes> extractChanges() {
    Map<String, Changes> changeMap = new HashMap<>();

    List<ImmutablePair<String, String>> changedFiles = Util.getFilesChanged(patch);
    // FIXME: for now, we'll just assume no files were added or deleted
    for (ImmutablePair<String, String> filePair : changedFiles) {
        String oldFileName = filePair.getLeft();
        String newFileName = filePair.getRight();
        Changes changesForThisFile = new Changes();
        Map<Class, List<String>> resultsForOldFile = oldResults.getResultsFor(oldFileName);
        Map<Class, List<String>> resultsForNewFile = newResults.getResultsFor(newFileName);
        Set<Class> toolsUsed = resultsForOldFile.keySet();
        assert toolsUsed.equals(resultsForNewFile.keySet());

        // for each tool, go through and detect changes
        for (Class toolUsed : toolsUsed) {
            List<String> oldResultListFromThisTool = resultsForOldFile.get(toolUsed);
            List<String> newResultListFromThisTool = resultsForNewFile.get(toolUsed);
            Set<String> oldResultsFromThisTool = new HashSet<>(oldResultListFromThisTool);
            Set<String> newResultsFromThisTool = new HashSet<>(newResultListFromThisTool);
            Set<String> additions = Sets.difference(newResultsFromThisTool, oldResultsFromThisTool);
            Set<String> subtractions = Sets.difference(oldResultsFromThisTool, newResultsFromThisTool);

            // construct the change
            List<String> additionList = Arrays.asList(additions.toArray(new String[additions.size()]));
            List<String> subtractionList = Arrays.asList(subtractions.toArray(new String[subtractions.size()]));
            ImmutablePair<List<String>, List<String>> changeListPair = ImmutablePair.of(additionList,
                    subtractionList);
            changesForThisFile.put(toolUsed, changeListPair);
        }

        changeMap.put(oldFileName, changesForThisFile);
    }

    return changeMap;
}

From source file:ubic.BAMSandAllen.adjacency.IdentityAdjacency.java

/**
 * Return the same matrix given./*from w  w  w.jav a  2  s. com*/
 */
public DoubleMatrix<String, String> getAdjacency(DoubleMatrix<String, String> toCompute) {
    Set<String> rowSet = new HashSet<String>(toCompute.getRowNames());
    Set<String> colSet = new HashSet<String>(toCompute.getColNames());
    if (!rowSet.equals(colSet)) {
        throw new RuntimeException("Not a square matrix with matching rows/cols");
    }
    // re-order the rows to be the same as cols
    DoubleMatrix<String, String> result = new DenseDoubleMatrix<String, String>(colSet.size(), colSet.size());
    result.setColumnNames(toCompute.getColNames());
    result.setRowNames(toCompute.getColNames());
    for (String row : colSet) {
        for (String col : colSet) {
            result.setByKeys(row, col, toCompute.getByKeys(row, col));
            result.setByKeys(col, row, toCompute.getByKeys(row, col));
        }
    }
    return result;
}

From source file:com.github.fge.jackson.JsonNumEquals.java

private boolean objectEquals(final JsonNode a, final JsonNode b) {
    /*//  ww  w  .  j a  v  a2  s  . c  om
     * Grab the key set from the first node
     */
    final Set<String> keys = Sets.newHashSet(a.fieldNames());

    /*
     * Grab the key set from the second node, and see if both sets are the
     * same. If not, objects are not equal, no need to check for children.
     */
    final Set<String> set = Sets.newHashSet(b.fieldNames());
    if (!set.equals(keys))
        return false;

    /*
     * Test each member individually.
     */
    for (final String key : keys)
        if (!doEquivalent(a.get(key), b.get(key)))
            return false;

    return true;
}

From source file:com.tacitknowledge.util.migration.MissingPatchMigrationRunnerStrategy.java

public boolean isSynchronized(PatchInfoStore currentPatchInfoStore, PatchInfoStore patchInfoStore)
        throws MigrationException {

    if (currentPatchInfoStore == null || patchInfoStore == null) {
        throw new IllegalArgumentException("currentPatchInfoStore and patchInfoStore should not be null");
    }//from w  w w  . java 2  s . c  o  m
    Set<Integer> currentPatchInfoStorePatchesApplied = currentPatchInfoStore.getPatchesApplied();
    Set<Integer> patchInfoStorePatchesApplied = patchInfoStore.getPatchesApplied();

    return currentPatchInfoStorePatchesApplied.equals(patchInfoStorePatchesApplied);
}

From source file:com.redhat.rhn.manager.user.UpdateUserCommand.java

/**
 * @param rolesIn The roles to set./* w  w w  .ja va  2 s.  c om*/
 */
public void setTemporaryRoles(Set<Role> rolesIn) {
    if (!rolesIn.equals(user.getRoles())) {
        rolesChanged = true;
        needsUpdate = true;
        temporaryRoles = rolesIn;
    }
}

From source file:org.wso2.charon.core.v2.schema.AbstractValidator.java

/**
 * check whether the given two lists are equal from the content irrespective of the order
 * @param l1/*from ww w .j  av a 2s . c  o m*/
 * @param l2
 * @return
 */
private static boolean checkListEquality(List<Object> l1, List<Object> l2) {
    final Set<Object> s1 = new HashSet(l1);
    final Set<Object> s2 = new HashSet(l2);

    return s1.equals(s2);
}

From source file:org.apache.hadoop.hive.ql.parse.MacroSemanticAnalyzer.java

@SuppressWarnings("unchecked")
private void analyzeCreateMacro(ASTNode ast) throws SemanticException {
    String functionName = ast.getChild(0).getText();

    // Temp macros are not allowed to have qualified names.
    if (FunctionUtils.isQualifiedFunctionName(functionName)) {
        throw new SemanticException("Temporary macro cannot be created with a qualified name.");
    }/*from  w  ww.ja  v a2s.c o  m*/

    List<FieldSchema> arguments = BaseSemanticAnalyzer.getColumns((ASTNode) ast.getChild(1), true);
    boolean isNoArgumentMacro = arguments.size() == 0;
    RowResolver rowResolver = new RowResolver();
    ArrayList<String> macroColNames = new ArrayList<String>(arguments.size());
    ArrayList<TypeInfo> macroColTypes = new ArrayList<TypeInfo>(arguments.size());
    final Set<String> actualColumnNames = new HashSet<String>();

    if (!isNoArgumentMacro) {
        /*
         * Walk down expression to see which arguments are actually used.
         */
        Node expression = (Node) ast.getChild(2);
        PreOrderWalker walker = new PreOrderWalker(new Dispatcher() {
            @Override
            public Object dispatch(Node nd, Stack<Node> stack, Object... nodeOutputs) throws SemanticException {
                if (nd instanceof ASTNode) {
                    ASTNode node = (ASTNode) nd;
                    if (node.getType() == HiveParser.TOK_TABLE_OR_COL) {
                        actualColumnNames.add(node.getChild(0).getText());
                    }
                }
                return null;
            }
        });
        walker.startWalking(Collections.singletonList(expression), null);
    }
    for (FieldSchema argument : arguments) {
        TypeInfo colType = TypeInfoUtils.getTypeInfoFromTypeString(argument.getType());
        rowResolver.put("", argument.getName(), new ColumnInfo(argument.getName(), colType, "", false));
        macroColNames.add(argument.getName());
        macroColTypes.add(colType);
    }
    Set<String> expectedColumnNames = new LinkedHashSet<String>(macroColNames);
    if (!expectedColumnNames.equals(actualColumnNames)) {
        throw new SemanticException(
                "Expected columns " + expectedColumnNames + " but found " + actualColumnNames);
    }
    if (expectedColumnNames.size() != macroColNames.size()) {
        throw new SemanticException("At least one parameter name was used more than once " + macroColNames);
    }
    SemanticAnalyzer sa = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CBO_ENABLED)
            ? new CalcitePlanner(conf)
            : new SemanticAnalyzer(conf);
    ;
    ExprNodeDesc body;
    if (isNoArgumentMacro) {
        body = sa.genExprNodeDesc((ASTNode) ast.getChild(1), rowResolver);
    } else {
        body = sa.genExprNodeDesc((ASTNode) ast.getChild(2), rowResolver);
    }
    CreateMacroDesc desc = new CreateMacroDesc(functionName, macroColNames, macroColTypes, body);
    rootTasks.add(TaskFactory.get(new FunctionWork(desc), conf));

    addEntities();
}

From source file:io.seldon.items.RecentItemsWithTagsManager.java

public Map<Long, List<String>> retrieveRecentItems(String client, Set<Long> ids, int attrId, String table) {
    final String key = getKey(client, attrId, table);
    ItemTags items = clientStores.get(key);
    if (items != null && !ids.equals(items.ids)) {
        logger.info("Tag ids mismatch so setting items to null for " + client + " attrId:" + attrId + " table "
                + table);/*from www  . jav  a2  s  .  c  o  m*/
        items = null;
    }

    if (items == null) {
        if ((loading.putIfAbsent(key, true) == null)) {
            getRecentItems(client, ids, attrId, table);
        }
        return new HashMap<>();
    } else {
        if (dogpileHandler.updateIsRequired(key, items, CACHE_TIME_SECS)) {
            getRecentItems(client, ids, attrId, table);
        }

        return items.itemTags;
    }
}

From source file:org.apache.syncope.common.util.AttributableOperations.java

private static void populate(final Map<String, AttributeTO> updatedAttrs,
        final Map<String, AttributeTO> originalAttrs, final AbstractAttributableMod result,
        final boolean virtuals) {

    for (Map.Entry<String, AttributeTO> entry : updatedAttrs.entrySet()) {
        AttributeMod mod = new AttributeMod();
        mod.setSchema(entry.getKey());/*from  www . j a  v  a  2 s  . co m*/

        Set<String> updatedValues = new HashSet<String>(entry.getValue().getValues());

        Set<String> originalValues = originalAttrs.containsKey(entry.getKey())
                ? new HashSet<String>(originalAttrs.get(entry.getKey()).getValues())
                : Collections.<String>emptySet();

        if (!originalAttrs.containsKey(entry.getKey())) {
            // SYNCOPE-459: take care of user virtual attributes without any value
            updatedValues.remove("");
            mod.getValuesToBeAdded().addAll(new ArrayList<String>(updatedValues));

            if (virtuals) {
                result.getVirAttrsToUpdate().add(mod);
            } else {
                result.getAttrsToUpdate().add(mod);
            }
        } else if (!updatedValues.equals(originalValues)) {
            // avoid unwanted inputs
            updatedValues.remove("");
            if (!entry.getValue().isReadonly()) {
                mod.getValuesToBeAdded().addAll(updatedValues);

                if (!mod.isEmpty()) {
                    if (virtuals) {
                        result.getVirAttrsToRemove().add(mod.getSchema());
                    } else {
                        result.getAttrsToRemove().add(mod.getSchema());
                    }
                }
            }

            mod.getValuesToBeRemoved().addAll(originalValues);

            if (!mod.isEmpty()) {
                if (virtuals) {
                    result.getVirAttrsToUpdate().add(mod);
                } else {
                    result.getAttrsToUpdate().add(mod);
                }
            }
        }
    }
}