Example usage for com.google.common.collect ImmutableSet size

List of usage examples for com.google.common.collect ImmutableSet size

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:com.google.devtools.skylark.skylint.NativeRecursiveGlobChecker.java

@Override
public void visit(AssignmentStatement node) {
    super.visit(node);
    ImmutableSet<Identifier> lvalues = node.getLValue().boundIdentifiers();
    if (lvalues.size() != 1) {
        return;/*from   w w w .  j a  va 2 s . com*/
    }
    Identifier ident = Iterables.getOnlyElement(lvalues);
    vars.put(ident, node.getExpression());

    if (waitingFor.contains(ident)) {
        evaluateInclude(node.getExpression());
    }
}

From source file:edu.mit.streamjit.util.bytecode.Value.java

/**
 * Unregisters a use of this Value.  Should only be called by Use itself.
 * @param use the use to remove//from  w w w . j  ava  2s  . c  o m
 */
void removeUse(Use use) {
    assert use != null;
    //      assert ReflectionUtils.calledDirectlyFrom(Use.class);
    assert use.getOperand() == this : "Removing use of wrong object" + use + ", " + this;
    ImmutableSet.Builder<Use> builder = ImmutableSet.builder();
    for (Use u : uses)
        if (!Objects.equals(u, use))
            builder.add(u);
    ImmutableSet<Use> newUses = builder.build();
    assert newUses.size() == uses.size() - 1 : "Removing not-a-use use: " + use;
    this.uses = newUses;
}

From source file:org.sosy_lab.cpachecker.cpa.pointer2.util.ExplicitLocationSet.java

private ExplicitLocationSet(ImmutableSet<String> pLocations) {
    assert pLocations.size() >= 1;
    this.explicitSet = pLocations;
}

From source file:org.jclouds.sqs.options.ReceiveMessageOptions.java

@Override
public Multimap<String, String> buildFormParameters() {
    Multimap<String, String> params = super.buildFormParameters();
    if (visibilityTimeout != null)
        params.put("VisibilityTimeout", visibilityTimeout.toString());
    ImmutableSet<String> attributes = this.attributes.build();
    if (attributes.size() > 0) {
        int nameIndex = 1;
        for (String attribute : attributes) {
            params.put("AttributeName." + nameIndex, attribute);
            nameIndex++;//from  w w w .j  a v  a2 s  . co  m
        }
    }
    return params;
}

From source file:main.java.recognizer.Index.java

/**
 * Prints {@code words} information from the index.
 *///from   w  w  w.j a v  a2s.  c om
public void printLookup(Iterable<String> words) {
    ImmutableSet<String> hits = lookup(words);
    if (hits.size() == 0) {
        System.out.print("No hits found.\n\n");
    }
    for (String document : hits) {
        String text = "";
        try (Jedis jedis = pool.getResource()) {
            jedis.select(DOCS_DB);
            text = jedis.get(document);
        }
        System.out.printf("***Image %s has text:\n%s\n", document, text);
    }
}

From source file:org.n52.movingcode.runtime.coderepository.AbstractRepository.java

@Override
public PID[] getPackageIDs() {
    ImmutableSet<PID> s = inventory.getPackageIDs();
    return s.toArray(new PID[s.size()]);
}

From source file:com.google.devtools.skylark.skylint.BadOperationChecker.java

@Override
public void visit(AssignmentStatement node) {
    super.visit(node);
    ImmutableSet<Identifier> lvalues = node.getLValue().boundIdentifiers();
    if (lvalues.size() != 1) {
        return;//from w  w  w.j  av  a  2 s . com
    }
    Identifier ident = Iterables.getOnlyElement(lvalues);
    NodeType inferredType = getInferredTypeOrNull(node.getExpression());

    if (inferredType != null) {
        inferredTypeVariables.put(env.resolveName(ident.getName()).id, inferredType);
    }
}

From source file:org.artifactory.storage.db.build.entity.BuildEntity.java

public boolean isIdentical(BuildEntity b) {
    ImmutableSet<BuildProperty> oprops = b.getProperties();
    if (oprops.size() != getProperties().size()) {
        return false;
    }// w  w w . j  av a 2  s.  c  o m
    for (BuildProperty prop : properties) {
        boolean foundIdentical = false;
        for (BuildProperty oprop : oprops) {
            if (oprop.isIdentical(prop)) {
                foundIdentical = true;
            }
        }
        if (!foundIdentical) {
            return false;
        }
    }
    return Objects.equal(promotions, b.promotions) && StringUtils.equals(buildName, b.buildName)
            && StringUtils.equals(buildNumber, b.buildNumber) && buildDate == b.buildDate
            && StringUtils.equals(ciUrl, b.ciUrl) && created == b.created
            && StringUtils.equals(createdBy, b.createdBy) && modified == b.modified
            && StringUtils.equals(modifiedBy, b.modifiedBy);
}

From source file:org.n52.movingcode.runtime.coderepository.AbstractRepository.java

@Override
public String[] getFunctionIDs() {
    ImmutableSet<String> s = inventory.getFunctionIDs();
    return s.toArray(new String[s.size()]);
}

From source file:dagger.internal.codegen.InjectConstructorValidator.java

ValidationReport<TypeElement> validate(ExecutableElement constructorElement) {
    ValidationReport.Builder<TypeElement> builder = ValidationReport
            .about(MoreElements.asType(constructorElement.getEnclosingElement()));
    if (constructorElement.getModifiers().contains(PRIVATE)) {
        builder.addError(INJECT_ON_PRIVATE_CONSTRUCTOR, constructorElement);
    }/* ww  w . jav  a  2s  .  c  o m*/

    for (AnnotationMirror qualifier : getQualifiers(constructorElement)) {
        builder.addError(QUALIFIER_ON_INJECT_CONSTRUCTOR, constructorElement, qualifier);
    }

    for (VariableElement parameter : constructorElement.getParameters()) {
        ImmutableSet<? extends AnnotationMirror> qualifiers = getQualifiers(parameter);
        if (qualifiers.size() > 1) {
            for (AnnotationMirror qualifier : qualifiers) {
                builder.addError(MULTIPLE_QUALIFIERS, constructorElement, qualifier);
            }
        }
    }

    TypeElement enclosingElement = MoreElements.asType(constructorElement.getEnclosingElement());
    Set<Modifier> typeModifiers = enclosingElement.getModifiers();

    if (typeModifiers.contains(PRIVATE)) {
        builder.addError(INJECT_INTO_PRIVATE_CLASS, constructorElement);
    }

    if (typeModifiers.contains(ABSTRACT)) {
        builder.addError(INJECT_CONSTRUCTOR_ON_ABSTRACT_CLASS, constructorElement);
    }

    if (enclosingElement.getNestingKind().isNested() && !typeModifiers.contains(STATIC)) {
        builder.addError(INJECT_CONSTRUCTOR_ON_INNER_CLASS, constructorElement);
    }

    // This is computationally expensive, but probably preferable to a giant index
    FluentIterable<ExecutableElement> injectConstructors = FluentIterable
            .from(ElementFilter.constructorsIn(enclosingElement.getEnclosedElements()))
            .filter(new Predicate<ExecutableElement>() {
                @Override
                public boolean apply(ExecutableElement input) {
                    return isAnnotationPresent(input, Inject.class);
                }
            });

    if (injectConstructors.size() > 1) {
        builder.addError(MULTIPLE_INJECT_CONSTRUCTORS, constructorElement);
    }

    ImmutableSet<? extends AnnotationMirror> scopes = getScopes(enclosingElement);
    if (scopes.size() > 1) {
        for (AnnotationMirror scope : scopes) {
            builder.addError(MULTIPLE_SCOPES, enclosingElement, scope);
        }
    }

    return builder.build();
}