Example usage for com.google.common.collect ImmutableList equals

List of usage examples for com.google.common.collect ImmutableList equals

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList equals.

Prototype

@Override
    public boolean equals(@Nullable Object obj) 

Source Link

Usage

From source file:com.google.caliper.runner.instrument.BenchmarkMethods.java

/**
 * For instruments that use {@link #isTimeMethod} to identify their methods, this method checks
 * the {@link Method} appropriately./*from  w  w w.  ja  va 2  s  .c  o m*/
 */
static MethodModel checkTimeMethod(MethodModel timeMethod) throws InvalidBenchmarkException {
    checkArgument(isTimeMethod(timeMethod));
    ImmutableList<String> parameterTypes = timeMethod.parameterTypes();
    if (!parameterTypes.equals(MICROBENCHMARK_PARAMS) && !parameterTypes.equals(PICOBENCHMARK_PARAMS)) {
        throw new InvalidBenchmarkException(
                "Microbenchmark methods must accept a single int parameter: " + timeMethod.name());
    }

    // Static technically doesn't hurt anything, but it's just the completely wrong idea
    if (Modifier.isStatic(timeMethod.modifiers())) {
        throw new InvalidBenchmarkException("Microbenchmark methods must not be static: " + timeMethod.name());
    }
    return timeMethod;
}

From source file:org.ow2.authzforce.core.pdp.api.BaseDecisionResult.java

/** {@inheritDoc} */
@Override//  w ww . ja  va2 s .  c  o m
public final boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }

    if (!(obj instanceof DecisionResult)) {
        return false;
    }

    final DecisionResult other = (DecisionResult) obj;
    if (this.getDecision() != other.getDecision()
            || this.getExtendedIndeterminate() != other.getExtendedIndeterminate()) {
        return false;
    }

    // Status is optional in XACML
    if (!Objects.equals(this.status, other.getStatus())) {
        return false;
    }

    final ImmutableList<PepAction> otherPepActions = other.getPepActions();
    assert otherPepActions != null;
    final ImmutableList<PepAction> thisPepActions = this.getPepActions();

    return thisPepActions.equals(otherPepActions);
}

From source file:com.querydsl.core.support.ReplaceVisitor.java

@SuppressWarnings("unchecked")
@Override/* w  w  w . ja  va 2s.c o m*/
public Expression<?> visit(TemplateExpression<?> expr, C context) {
    ImmutableList.Builder builder = ImmutableList.builder();
    for (Object arg : expr.getArgs()) {
        if (arg instanceof Expression) {
            builder.add(((Expression<?>) arg).accept(this, context));
        } else {
            builder.add(arg);
        }
    }
    ImmutableList args = builder.build();
    if (args.equals(expr.getArgs())) {
        return expr;
    } else {
        if (expr instanceof Predicate) {
            return Expressions.booleanTemplate(expr.getTemplate(), args);
        } else {
            return ExpressionUtils.template(expr.getType(), expr.getTemplate(), args);
        }
    }
}

From source file:com.mysema.query.support.ReplaceVisitor.java

@Override
public Expression<?> visit(TemplateExpression<?> expr, @Nullable Void context) {
    ImmutableList.Builder builder = ImmutableList.builder();
    for (Object arg : expr.getArgs()) {
        if (arg instanceof Expression) {
            builder.add(((Expression) arg).accept(this, null));
        } else {/*from w w w .ja  v  a  2 s . c o  m*/
            builder.add(arg);
        }
    }
    ImmutableList args = builder.build();
    if (args.equals(expr.getArgs())) {
        return expr;
    } else {
        if (expr instanceof Predicate) {
            return BooleanTemplate.create(expr.getTemplate(), args);
        } else {
            return new TemplateExpressionImpl(expr.getType(), expr.getTemplate(), args);
        }
    }
}

From source file:com.mysema.query.support.ReplaceVisitor.java

@Override
public Expression<?> visit(Operation<?> expr, @Nullable Void context) {
    ImmutableList<Expression<?>> args = visit(expr.getArgs());
    if (args.equals(expr.getArgs())) {
        return expr;
    } else if (expr instanceof Predicate) {
        return new PredicateOperation((Operator) expr.getOperator(), args);
    } else {/*from w  ww  . ja va 2 s  .  co  m*/
        return new OperationImpl(expr.getType(), expr.getOperator(), args);
    }
}

From source file:com.querydsl.core.support.ReplaceVisitor.java

@Override
public Expression<?> visit(Operation<?> expr, C context) {
    ImmutableList<Expression<?>> args = visit(expr.getArgs(), context);
    if (args.equals(expr.getArgs())) {
        return expr;
    } else if (expr instanceof Predicate) {
        return ExpressionUtils.predicate(expr.getOperator(), args);
    } else {/*from ww  w .  jav a  2 s.  c  o m*/
        return ExpressionUtils.operation(expr.getType(), expr.getOperator(), args);
    }
}

From source file:co.jirm.orm.dao.JirmDao.java

public void insertMaps(Iterator<Map<String, Object>> values, int batchSize) {
    if (!values.hasNext())
        return;/*from  ww w  . j a  v  a2  s  . c om*/
    PeekingIterator<Map<String, Object>> vs = peekingIterator(values);
    Map<String, Object> first = vs.peek();
    final String sql = writerStrategy.insertStatement(new StringBuilder(), definition, first).toString();
    ImmutableList<String> keys = ImmutableList.copyOf(vs.peek().keySet());
    Iterator<List<Map<String, Object>>> it = partition(vs, batchSize);

    while (it.hasNext()) {
        List<Map<String, Object>> batch = it.next();
        final List<Object[]> batchValues = Lists.newArrayListWithExpectedSize(batch.size());
        for (Map<String, Object> b : batch) {
            ImmutableList<String> actualKeys = ImmutableList.copyOf(b.keySet());
            check.state(actualKeys.equals(keys), "Keys don't match up to {} for {}", keys, actualKeys);
            batchValues.add(writerStrategy.fillValues(definition, b).toArray());
        }
        /*
         * TODO this will keep making a prepared statementS.
         * Hopefully the JDBC driver has some caching for this.
         */
        sqlExecutor.batchUpdate(sql, batchValues);
    }

}

From source file:org.openo.msb.wrapper.consul.cache.ConsulCache4Map.java

ConsulCache4Map(CallbackConsumer<V> callbackConsumer, final long backoffDelayQty,
        final TimeUnit backoffDelayUnit) {

    this.callBackConsumer = callbackConsumer;

    this.responseCallback = new ConsulResponseCallback<Map<String, List<String>>>() {
        @Override/*from w w  w  .  j  ava  2  s.  c  o  m*/
        public void onComplete(ConsulResponse<Map<String, List<String>>> consulResponse) {

            if (!isRunning()) {
                return;
            }
            updateIndex(consulResponse);
            ImmutableList<ServiceInfo> full = convertToList(consulResponse);
            List<ServiceInfo> oldList = lastResponse.get();
            boolean changed = !full.equals(lastResponse.get());
            //                LOGGER.info("service changed:"+changed+"----"+full);
            if (changed) {
                // changes
                lastResponse.set(full);
            }

            if (changed) {
                for (Listener<K, V> l : listeners) {
                    l.notify(oldList, full);
                }
            }

            if (state.compareAndSet(State.starting, State.started)) {
                initLatch.countDown();
            }
            runCallback();
        }

        @Override
        public void onFailure(Throwable throwable) {

            if (!isRunning()) {
                return;
            }
            LOGGER.error(String.format("Error getting response from consul. will retry in %d %s",
                    backoffDelayQty, backoffDelayUnit), throwable);

            executorService.schedule(new Runnable() {
                @Override
                public void run() {
                    runCallback();
                }
            }, backoffDelayQty, backoffDelayUnit);
        }
    };
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticmi.read.InterfaceInformationFlowConsistencyValidator.java

@Override
public boolean validate(Model model, MessageListener messageListener) {
    if (isSentientMode()) {
        LOGGER.warn("Can't perform model validation! The metamodel is in invalid state for this validator.");
        return true;
    }//w  w  w . j a  v a  2s. co m

    boolean result = true;

    Collection<ObjectExpression> allISIs = informationSystemInterface.apply(model).getMany();
    for (ObjectExpression isi : allISIs) {

        ElasticValue<ObjectExpression> connectedInfoFlowEV = isiToIf.apply(isi);
        if (connectedInfoFlowEV.isMany()) {
            PeekingIterator<ObjectExpression> infoFlowsIterator = Iterators
                    .peekingIterator(connectedInfoFlowEV.getMany().iterator());

            while (infoFlowsIterator.hasNext()) {
                ObjectExpression currentInfoFlow = infoFlowsIterator.next();

                ElasticValue<ObjectExpression> currentIsr1EV = ifToIsr1.apply(currentInfoFlow);
                ElasticValue<ObjectExpression> currentIsr2EV = ifToIsr2.apply(currentInfoFlow);
                // check if exactly two ISR are connected:
                if (!(currentIsr1EV.isOne() && currentIsr2EV.isOne())) {
                    result = false;
                    String nameOfInterface = getNameOrDefault(informationSystemInterface, isi, "NULL", ",");
                    String nameOfInfoFlow = getNameOrDefault(informationFlow, currentInfoFlow, "NULL", ",");
                    messageListener.onMessage(new InterfaceInformationFlowConsistencyViolationMessage(
                            nameOfInterface, nameOfInfoFlow));
                    continue;
                }

                if (!infoFlowsIterator.hasNext()) {
                    break; // reached last pair
                }
                ObjectExpression nextInfoFlow = infoFlowsIterator.peek();
                ElasticValue<ObjectExpression> nextIsr1EV = ifToIsr1.apply(nextInfoFlow);
                ElasticValue<ObjectExpression> nextIsr2EV = ifToIsr2.apply(nextInfoFlow);
                if (!(nextIsr1EV.isOne() && nextIsr2EV.isOne())) {
                    continue;
                }

                // check if connected ISR and/or their order are equal compared to the previous InformationFlow:
                ImmutableList<ObjectExpression> currentList = ImmutableList.of(currentIsr1EV.getOne(),
                        currentIsr2EV.getOne());
                ImmutableList<ObjectExpression> nextList = ImmutableList.of(nextIsr1EV.getOne(),
                        nextIsr2EV.getOne());

                if (!currentList.equals(nextList)) {
                    result = false;
                    String nameOfInterface = getNameOrDefault(informationSystemInterface, isi, "NULL", ", ");
                    String nameOfInfoFlow1 = getNameOrDefault(informationFlow, currentInfoFlow, "NULL", ",");
                    String nameOfInfoFlow2 = getNameOrDefault(informationFlow, nextInfoFlow, "NULL", ",");
                    messageListener.onMessage(new InterfaceInformationFlowConsistencyViolationMessage(
                            nameOfInterface, nameOfInfoFlow1, nameOfInfoFlow2));
                }
            }
        }
    }
    return result;
}

From source file:google.registry.request.auth.RequestAuthenticator.java

/** Validates an Auth object, checking for invalid setting combinations. */
void checkAuthConfig(Auth auth) {
    ImmutableList<Auth.AuthMethod> authMethods = ImmutableList.copyOf(auth.methods());
    checkArgument(!authMethods.isEmpty(), "Must specify at least one auth method");
    checkArgument(/* ww  w.j a v a 2  s  .co m*/
            Ordering.explicit(Auth.AuthMethod.INTERNAL, Auth.AuthMethod.API, Auth.AuthMethod.LEGACY)
                    .isStrictlyOrdered(authMethods),
            "Auth methods must be unique and strictly in order - INTERNAL, API, LEGACY");
    checkArgument(authMethods.contains(Auth.AuthMethod.INTERNAL),
            "Auth method INTERNAL must always be specified, and as the first auth method");
    if (authMethods.equals(ImmutableList.of(Auth.AuthMethod.INTERNAL))) {
        checkArgument(!auth.minimumLevel().equals(AuthLevel.USER),
                "Actions with only INTERNAL auth may not require USER auth level");
    } else {
        checkArgument(!auth.userPolicy().equals(Auth.UserPolicy.IGNORED),
                "Actions with auth methods beyond INTERNAL must not specify the IGNORED user policy");
    }
}