Example usage for com.google.common.collect Iterables isEmpty

List of usage examples for com.google.common.collect Iterables isEmpty

Introduction

In this page you can find the example usage for com.google.common.collect Iterables isEmpty.

Prototype

public static boolean isEmpty(Iterable<?> iterable) 

Source Link

Document

Determines if the given iterable contains no elements.

Usage

From source file:com.google.devtools.build.lib.analysis.TargetCompleteEvent.java

/**
 * Construct a target completion event for a failed target, with the given non-empty root causes.
 *///  w  w  w  .  ja v  a 2 s  .  co  m
public static TargetCompleteEvent createFailed(ConfiguredTarget ct, NestedSet<Cause> rootCauses) {
    Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
    return new TargetCompleteEvent(ct, rootCauses, false);
}

From source file:org.sonar.maven.MavenAnalyzer.java

public void scan(Iterable<File> files) {
    boolean hasMavenFileScanners = !scanners.isEmpty();
    boolean hasPomFile = !Iterables.isEmpty(files);
    if (hasMavenFileScanners && !hasPomFile) {
        LOG.warn("No 'pom.xml' file have been indexed.");
        return;/* w  w  w  .  jav a  2 s.c o m*/
    }

    ProgressReport progressReport = new ProgressReport("Report about progress of Maven Pom analyzer",
            TimeUnit.SECONDS.toMillis(10));
    progressReport.start(Lists.newArrayList(files));

    boolean successfulyCompleted = false;
    try {
        for (File file : files) {
            simpleScan(file);
            progressReport.nextFile();
        }
        successfulyCompleted = true;
    } finally {
        if (successfulyCompleted) {
            progressReport.stop();
        } else {
            progressReport.cancel();
        }
    }

}

From source file:org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect.java

/**
 * Get the source callsite (the full {@link TmfCallsite} information) from a
 * binary callsite.//from ww w .j  av  a 2 s.c  o m
 *
 * @param trace
 *            The trace, which may contain trace-specific configuration
 * @param bc
 *            The binary callsite
 * @return The source callsite, which sould include file name, function name
 *         and line number
 */
public static @Nullable SourceCallsite getSourceCallsite(LttngUstTrace trace, BinaryCallsite bc) {
    Iterable<SourceCallsite> callsites = FileOffsetMapper
            .getCallsiteFromOffset(new File(bc.getBinaryFilePath()), bc.getBuildId(), bc.getOffset());

    if (callsites == null || Iterables.isEmpty(callsites)) {
        return null;
    }
    /*
     * TMF only supports the notion of one callsite per event at the moment.
     * We will take the "deepest" one in the stack, which should refer to
     * the initial, non-inlined location.
     */
    SourceCallsite callsite = Iterables.getLast(callsites);

    /*
     * Apply the path prefix again, this time on the path given from
     * addr2line. If applicable.
     */
    String pathPrefix = trace.getSymbolProviderConfig().getActualRootDirPath();
    if (pathPrefix.isEmpty()) {
        return callsite;
    }

    String fullFileName = (pathPrefix + callsite.getFileName());
    return new SourceCallsite(fullFileName, callsite.getFunctionName(), callsite.getLineNumber());
}

From source file:com.codebullets.external.party.simulator.connections.ConnectionLoader.java

/**
 * Loads all connections from configuration and starts them.
 *///from  w  w w.j  a v a 2  s  .c om
public void startAllConnections() {
    Iterable<Path> connectionSettings = findAllConnectionSettings();

    ConnectionConfigurator connectionConfigurator = new ConnectionConfigurator();
    Iterable<ConnectionConfig> connectionConfigs = connectionConfigurator.readConnections(connectionSettings);
    if (Iterables.isEmpty(connectionConfigs)) {
        LOG.warn(
                "No connection setting found. Please make sure the configuration is in either the connections sub folder or "
                        + "the 'simulator.connections' system property points to the target location.");
    }

    printConfig(connectionConfigs);

    for (ConnectionConfig connectionConfig : connectionConfigs) {
        startConnection(connectionConfig);
    }
}

From source file:com.google.devtools.build.lib.query2.engine.SomeFunction.java

@Override
public <T> void eval(QueryEnvironment<T> env, VariableContext<T> context, QueryExpression expression,
        List<Argument> args, final Callback<T> callback) throws QueryException, InterruptedException {
    final AtomicBoolean someFound = new AtomicBoolean(false);
    env.eval(args.get(0).getExpression(), context, new Callback<T>() {
        @Override//www.j a va  2s  .com
        public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
            if (someFound.get() || Iterables.isEmpty(partialResult)) {
                return;
            }
            callback.process(ImmutableSet.of(partialResult.iterator().next()));
            someFound.set(true);
        }
    });
    if (!someFound.get()) {
        throw new QueryException(expression, "argument set is empty");
    }
}

From source file:com.eucalyptus.autoscaling.common.internal.configurations.LaunchConfigurations.java

public static boolean containsSecurityGroupIdentifiers(final Iterable<String> groups) {
    return !Iterables.isEmpty(groups) && Iterables.get(groups, 0).matches("sg-[0-9A-Fa-f]{8}");
}

From source file:org.terasology.engine.subsystem.common.ConfigurationSubsystem.java

@Override
public void preInitialise(Context rootContext) {
    config = new Config();
    config.load();/*from w w w.j  av a 2s  .c o m*/

    String serverPortProperty = System.getProperty(SERVER_PORT_PROPERTY);
    if (serverPortProperty != null) {
        try {
            config.getNetwork().setServerPort(Integer.parseInt(serverPortProperty));
        } catch (NumberFormatException e) {
            logger.error("Failed to set server port to invalid value: {}", serverPortProperty);
        }
    }

    if (Iterables.isEmpty(config.getDefaultModSelection().listModules())) {
        config.getDefaultModSelection().addModule(TerasologyConstants.CORE_GAMEPLAY_MODULE);
    }

    checkServerIdentity();

    // TODO: Move to display subsystem
    logger.info("Video Settings: {}", config.renderConfigAsJson(config.getRendering()));
    rootContext.put(Config.class, config);
}

From source file:com.google.devtools.j2objc.gen.TypePrivateDeclarationGenerator.java

private void printClassExtension() {
    if (isInterfaceType()) {
        return;/*  w ww .ja v  a2 s. c o  m*/
    }
    boolean hasPrivateFields = !Iterables.isEmpty(getInstanceFields());
    Iterable<BodyDeclaration> privateDecls = getInnerDeclarations();
    if (!Iterables.isEmpty(privateDecls) || hasPrivateFields) {
        newline();
        printf("@interface %s ()", typeName);
        printInstanceVariables();
        printDeclarations(privateDecls);
        println("\n@end");
    }
}

From source file:guru.qas.martini.tag.DefaultCategories.java

@Override
public void afterPropertiesSet() throws Exception {
    Map<String, Category> beans = applicationContext.getBeansOfType(Category.class);
    Collection<Category> categories = beans.values();

    for (Category category : categories) {
        String name = category.getName();
        Iterable<String> parentNames = category.getParentNames();

        if (Iterables.isEmpty(parentNames)) {
            ascendingHierarchy.put(name, null);
        } else {/*from  w  ww  . j ava  2s . c o m*/
            for (String parentName : parentNames) {
                ascendingHierarchy.put(name, parentName);
            }
        }
    }
}

From source file:org.sonar.java.checks.xml.struts.ActionNumberCheck.java

@Override
public void scanFileWithXPathExpressions(XmlCheckContext context) {
    for (Node action : context.evaluateOnDocument(actionsExpression)) {
        Iterable<Node> extraForwards = Iterables.skip(context.evaluate(forwardsFromActionExpression, action),
                maximumForwards);//from  w ww.j a va  2s .  com
        if (!Iterables.isEmpty(extraForwards)) {
            List<XmlCheckContext.XmlDocumentLocation> secondaries = new LinkedList<>();
            for (Node forward : extraForwards) {
                secondaries.add(new XmlCheckContext.XmlDocumentLocation("Move this forward to another action.",
                        forward));
            }
            int cost = secondaries.size();
            int numberForward = maximumForwards + cost;
            String message = "Reduce the number of forwards in this action from " + numberForward
                    + " to at most " + maximumForwards + ".";
            context.reportIssue(this, action, message, secondaries, cost);
        }
    }
}