Example usage for java.util EnumSet equals

List of usage examples for java.util EnumSet equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.opengamma.engine.exec.DefaultAggregatedExecutionLog.java

/**
 * Constructs an instance for a root level with possible logs from its dependencies when the full logging mode is being used.
 * /*  ww w.ja v a2  s.  c  om*/
 * @param node the node this log has come from, not null
 * @param rootLog the root log, not null
 * @param dependentLogs the dependent logs, if any, may be null or empty
 * @return the log instance
 */
public static DefaultAggregatedExecutionLog fullLogMode(DependencyNode node, ExecutionLog rootLog,
        Collection<AggregatedExecutionLog> dependentLogs) {
    ArgumentChecker.notNull(node, "node");
    ArgumentChecker.notNull(rootLog, "rootLog");
    EnumSet<LogLevel> logLevels = rootLog.getLogLevels();
    boolean logLevelsCopied = false;
    final List<ExecutionLogWithContext> logs = new ArrayList<ExecutionLogWithContext>();
    boolean emptyRoot = rootLog.isEmpty();
    if (!emptyRoot) {
        logs.add(ExecutionLogWithContext.of(node, rootLog));
    }
    if (dependentLogs != null) {
        for (AggregatedExecutionLog dependentLog : dependentLogs) {
            final EnumSet<LogLevel> dependentLogLevels = dependentLog.getLogLevels();
            if (logLevelsCopied) {
                logLevels.addAll(dependentLogLevels);
            } else {
                if (!logLevels.equals(dependentLogLevels)) {
                    logLevels = EnumSet.copyOf(logLevels);
                    logLevels.addAll(dependentLogLevels);
                    logLevelsCopied = true;
                }
            }
            if (logs != null && dependentLog.getLogs() != null) {
                logs.addAll(dependentLog.getLogs());
            }
        }
    }
    return new DefaultAggregatedExecutionLog(logLevels, logs, emptyRoot);
}

From source file:fr.duminy.components.swing.listpanel.ListPanelFixture.java

public ListPanelFixture<B, C> requireOnlyFeatures(StandardListPanelFeature... expectedFeatures) {
    EnumSet<StandardListPanelFeature> actualFeatures = ListPanelTest.getActualFeatures(listPanel());

    if (!actualFeatures.equals(ListPanelTest.copyOf(StandardListPanelFeature.class, expectedFeatures))) {
        String message = String.format(
                "The ListPanel '%s' must have only features {%s} but has actual features {%s}",
                component().getName(), StringUtils.join(expectedFeatures, ','),
                StringUtils.join(actualFeatures, ','));
        throw new IllegalStateException(message);
    }/*from   w  ww.  jav a 2 s.c o  m*/

    return this;
}

From source file:com.google.bitcoin.core.Wallet.java

/**
 * <p>Called when we have found a transaction (via network broadcast or otherwise) that is relevant to this wallet
 * and want to record it. Note that we <b>cannot verify these transactions at all</b>, they may spend fictional
 * coins or be otherwise invalid. They are useful to inform the user about coins they can expect to receive soon,
 * and if you trust the sender of the transaction you can choose to assume they are in fact valid and will not
 * be double spent as an optimization.</p>
 *
 * <p>This is the same as {@link Wallet#receivePending(Transaction, java.util.List)} but allows you to override the
 * {@link Wallet#isPendingTransactionRelevant(Transaction)} sanity-check to keep track of transactions that are not
 * spendable or spend our coins. This can be useful when you want to keep track of transaction confidence on
 * arbitrary transactions. Note that transactions added in this way will still be relayed to peers and appear in
 * transaction lists like any other pending transaction (even when not relevant).</p>
 *//*  w w w  .  ja  va 2 s .co  m*/
public void receivePending(Transaction tx, @Nullable List<Transaction> dependencies, boolean overrideIsRelevant)
        throws VerificationException {
    // Can run in a peer thread. This method will only be called if a prior call to isPendingTransactionRelevant
    // returned true, so we already know by this point that it sends coins to or from our wallet, or is a double
    // spend against one of our other pending transactions.
    lock.lock();
    try {
        tx.verify();
        // Ignore it if we already know about this transaction. Receiving a pending transaction never moves it
        // between pools.
        EnumSet<Pool> containingPools = getContainingPools(tx);
        if (!containingPools.equals(EnumSet.noneOf(Pool.class))) {
            log.debug("Received tx we already saw in a block or created ourselves: " + tx.getHashAsString());
            return;
        }
        // Repeat the check of relevancy here, even though the caller may have already done so - this is to avoid
        // race conditions where receivePending may be being called in parallel.
        if (!overrideIsRelevant && !isPendingTransactionRelevant(tx))
            return;
        if (isTransactionRisky(tx, dependencies) && !acceptRiskyTransactions)
            return;
        if (tx.getConfidence().getSource().equals(TransactionConfidence.Source.UNKNOWN)) {
            log.warn("Wallet received transaction with an unknown source. Consider tagging it!");
        }
        // If this tx spends any of our unspent outputs, mark them as spent now, then add to the pending pool. This
        // ensures that if some other client that has our keys broadcasts a spend we stay in sync. Also updates the
        // timestamp on the transaction and registers/runs event listeners.
        commitTx(tx);
    } finally {
        lock.unlock();
    }
    // maybeRotateKeys() will ignore pending transactions so we don't bother calling it here (see the comments
    // in that function for an explanation of why).
}

From source file:com.google.bitcoin.core.Wallet.java

/**
 * This method is used by a {@link Peer} to find out if a transaction that has been announced is interesting,
 * that is, whether we should bother downloading its dependencies and exploring the transaction to decide how
 * risky it is. If this method returns true then {@link Wallet#receivePending(Transaction, java.util.List)}
 * will soon be called with the transactions dependencies as well.
 *///from  www.j ava  2s  . c om
public boolean isPendingTransactionRelevant(Transaction tx) throws ScriptException {
    lock.lock();
    try {
        // Ignore it if we already know about this transaction. Receiving a pending transaction never moves it
        // between pools.
        log.info("!!!! isPendingTransactionRelevant START " + tx.getHashAsString());
        EnumSet<Pool> containingPools = getContainingPools(tx);
        if (!containingPools.equals(EnumSet.noneOf(Pool.class))) {
            log.debug("Received tx we already saw in a block or created ourselves: " + tx.getHashAsString());
            return false;
        }
        log.info("!!!! isPendingTransactionRelevant NOT IN POOLS " + tx.getHashAsString());

        // We only care about transactions that:
        //   - Send us coins
        //   - Spend our coins
        if (!isTransactionRelevant(tx)) {
            return false;
        }
        log.info("!!!! isPendingTransactionRelevant IS RELEVANT " + tx.getHashAsString());

        if (isTransactionRisky(tx, null) && !acceptRiskyTransactions) {
            log.warn(
                    "Received transaction {} with a lock time of {}, but not configured to accept these, discarding",
                    tx.getHashAsString(), tx.getLockTime());
            return false;
        }
        log.debug("Saw relevant pending transaction " + tx.toString());
        log.info("!!!! isPendingTransactionRelevant NOT RISKY " + tx.getHashAsString());

        return true;
    } finally {
        lock.unlock();
    }
}

From source file:org.pentaho.platform.repository2.unified.DefaultUnifiedRepositorySpecialCharacterTest.java

private void assertLocalAceExists(final RepositoryFile file, final RepositoryFileSid sid,
        final EnumSet<RepositoryFilePermission> permissions) {
    RepositoryFileAcl acl = repo.getAcl(file.getId());

    List<RepositoryFileAce> aces = acl.getAces();
    for (int i = 0; i < aces.size(); i++) {
        RepositoryFileAce ace = aces.get(i);
        if (sid.equals(ace.getSid()) && permissions.equals(ace.getPermissions())) {
            return;
        }//from w ww  .j a v a 2  s . c o  m
    }
    fail();
}