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

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

Introduction

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

Prototype

public static String toString(Iterable<?> iterable) 

Source Link

Document

Returns a string representation of iterable , with the format [e1, e2, ..., en] (that is, identical to java.util.Arrays Arrays .toString(Iterables.toArray(iterable)) ).

Usage

From source file:edu.umn.msi.tropix.webgui.server.LoginServiceImpl.java

@ServiceMethod(secure = false, readOnly = true)
public LoginInfo getUserIfLoggedIn() {
    final LoginInfo loginInfo = new LoginInfo();
    if (userSession.isLoggedIn()) {
        loginInfo.setSessionInfo(getSessionInfo());
    } else {/* ww w. j  a v a  2s.  co m*/
        loginInfo.setAllowGuestLogin(allowGuestLogin);
        final Iterable<String> authenticationSources = authenticationSourceManager
                .getAuthenticationSourceKeys();
        LOG.trace("Returning authenticationSources " + Iterables.toString(authenticationSources));
        loginInfo.setAuthenticationServices(Lists.newArrayList(authenticationSources));
    }
    return loginInfo;
}

From source file:org.eclipse.xtend.maven.AbstractXtendCompilerMojo.java

protected void compile(String classPath, List<String> sourcePaths, String outputPath)
        throws MojoExecutionException {
    XtendBatchCompiler compiler = getBatchCompiler();
    Log log = getLog();//from   w  w w.ja va  2  s .  c om
    compiler.setResourceSetProvider(new MavenProjectResourceSetProvider(project));
    Iterable<String> filtered = filter(sourcePaths, FILE_EXISTS);
    if (Iterables.isEmpty(filtered)) {
        String dir = Iterables.toString(sourcePaths);
        log.info("skip compiling sources because the configured directory '" + dir + "' does not exist.");
        return;
    }
    String baseDir = project.getBasedir().getAbsolutePath();
    log.debug("Set Java Compliance Level: " + javaSourceVersion);
    compiler.setJavaSourceVersion(javaSourceVersion);
    log.debug("Set generateSyntheticSuppressWarnings: " + generateSyntheticSuppressWarnings);
    compiler.setGenerateSyntheticSuppressWarnings(generateSyntheticSuppressWarnings);
    log.debug("Set generateGeneratedAnnotation: " + generateGeneratedAnnotation);
    compiler.setGenerateGeneratedAnnotation(generateGeneratedAnnotation);
    log.debug("Set includeDateInGeneratedAnnotation: " + includeDateInGeneratedAnnotation);
    compiler.setIncludeDateInGeneratedAnnotation(includeDateInGeneratedAnnotation);
    log.debug("Set generatedAnnotationComment: " + generatedAnnotationComment);
    compiler.setGeneratedAnnotationComment(generatedAnnotationComment);
    log.debug("Set baseDir: " + baseDir);
    compiler.setBasePath(baseDir);
    log.debug("Set temp directory: " + getTempDirectory());
    compiler.setTempDirectory(getTempDirectory());
    log.debug("Set DeleteTempDirectory: " + false);
    compiler.setDeleteTempDirectory(false);
    log.debug("Set classpath: " + classPath);
    compiler.setClassPath(classPath);
    String bootClassPath = getBootClassPath();
    log.debug("Set bootClasspath: " + bootClassPath);
    compiler.setBootClassPath(bootClassPath);
    log.debug("Set source path: " + concat(File.pathSeparator, newArrayList(filtered)));
    compiler.setSourcePath(concat(File.pathSeparator, newArrayList(filtered)));
    log.debug("Set output path: " + outputPath);
    compiler.setOutputPath(outputPath);
    log.debug("Set encoding: " + encoding);
    compiler.setFileEncoding(encoding);
    log.debug("Set writeTraceFiles: " + writeTraceFiles);
    compiler.setWriteTraceFiles(writeTraceFiles);
    if (!compiler.compile()) {
        String dir = concat(File.pathSeparator, newArrayList(filtered));
        throw new MojoExecutionException("Error compiling xtend sources in '" + dir + "'.");
    }
}

From source file:eu.interedition.collatex.jung.JungVariantGraph.java

@Override
public String toString() {
    return Iterables.toString(witnesses());
}

From source file:com.palantir.common.collect.IterableUtils.java

public static <T, U> Iterable<Pair<T, U>> zip(final Iterable<? extends T> it1,
        final Iterable<? extends U> it2) {
    return new Iterable<Pair<T, U>>() {
        @Override//from w  w  w. j  a  v a  2s.c  o m
        public Iterator<Pair<T, U>> iterator() {
            return IteratorUtils.zip(it1.iterator(), it2.iterator());
        }

        @Override
        public String toString() {
            return Iterables.toString(this);
        }
    };
}

From source file:au.edu.uq.nmerge.graph.VariantGraphMatch.java

/**
 * We need this for debugging/*from ww w .  j a v  a  2s.c o m*/
 * (different from MergeTester but only used for debugging)
 */
public String toString() {
    int offset = graphOffset + dataOffset;
    return "Version: " + version + " offset=" + offset + " length=" + length + " data="
            + Iterables.toString(data);
}

From source file:brooklyn.location.docker.DockerLocation.java

@Override
public MachineLocation obtain(Map<?, ?> flags) throws NoMachinesAvailableException {
    // Check context for entity being deployed
    Object context = flags.get(LocationConfigKeys.CALLER_CONTEXT.getName());
    if (context != null && !(context instanceof Entity)) {
        throw new IllegalStateException("Invalid location context: " + context);
    }/*from   w w  w. ja  va 2 s .  com*/
    Entity entity = (Entity) context;

    // Get the available hosts based on placement strategies
    List<DockerHostLocation> available = getDockerHostLocations();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Placement for: {}",
                Iterables.toString(Iterables.transform(available, EntityFunctions.id())));
    }
    for (DockerAwarePlacementStrategy strategy : strategies) {
        available = strategy.filterLocations(available, entity);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Placement after {}: {}", strategy,
                    Iterables.toString(Iterables.transform(available, EntityFunctions.id())));
        }
    }
    List<DockerAwarePlacementStrategy> entityStrategies = entity.config()
            .get(DockerAttributes.PLACEMENT_STRATEGIES);
    if (entityStrategies != null && entityStrategies.size() > 0) {
        for (DockerAwarePlacementStrategy strategy : entityStrategies) {
            available = strategy.filterLocations(available, entity);
        }
    } else {
        entityStrategies = ImmutableList.of();
    }

    // Use the docker strategy to add a new host
    DockerHostLocation machine = null;
    DockerHost dockerHost = null;
    if (available.size() > 0) {
        machine = available.get(0);
        dockerHost = machine.getOwner();
    } else {
        // Get permission to create a new Docker host
        if (permit.tryAcquire()) {
            try {
                Iterable<DockerAwareProvisioningStrategy> provisioningStrategies = Iterables.filter(
                        Iterables.concat(strategies, entityStrategies), DockerAwareProvisioningStrategy.class);
                for (DockerAwareProvisioningStrategy strategy : provisioningStrategies) {
                    flags = strategy.apply((Map<String, Object>) flags);
                }

                LOG.info("Provisioning new host with flags: {}", flags);
                SshMachineLocation provisioned = getProvisioner().obtain(flags);
                Entity added = getDockerInfrastructure().getDockerHostCluster().addNode(provisioned,
                        MutableMap.of());
                dockerHost = (DockerHost) added;
                machine = dockerHost.getDynamicLocation();
                Entities.start(added, ImmutableList.of(provisioned));
            } finally {
                permit.release();
            }
        } else {
            // Wait until whoever has the permit releases it, and try again
            try {
                permit.acquire();
            } catch (InterruptedException ie) {
                Exceptions.propagate(ie);
            } finally {
                permit.release();
            }
            return obtain(flags);
        }
    }

    // Now wait until the host has started up
    Entities.waitForServiceUp(dockerHost);

    // Obtain a new Docker container location, save and return it
    if (LOG.isDebugEnabled()) {
        LOG.debug("Obtain a new container from {} for {}", machine, entity);
    }
    Map<?, ?> hostFlags = MutableMap.copyOf(flags);
    DockerContainerLocation container = machine.obtain(hostFlags);
    containers.put(machine, container.getId());
    return container;
}

From source file:org.impressivecode.depress.mg.po.PeopleOrganizationMetricsNodeModel.java

private void configureChangeHistoryDataSpec(final DataTableSpec dataTableSpec) throws InvalidSettingsException {
    Set<String> missing = findMissingColumnSubset(dataTableSpec, createHistoryColumnSpec());
    if (!missing.isEmpty()) {
        throw new InvalidSettingsException("History data table does not contain required columns. Missing: "
                + Iterables.toString(missing));
    } else {/*  www. ja v  a2  s . co  m*/
        this.historyDataSpec = dataTableSpec;
    }
}

From source file:clocker.docker.location.strategy.basic.GroupPlacementStrategy.java

@Override
public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity entity) {
    if (locations == null || locations.isEmpty()) {
        return ImmutableList.of();
    }//from  w  w  w .  j a v  a  2  s  . com
    if (getDockerInfrastructure() == null)
        config().set(DOCKER_INFRASTRUCTURE, Iterables.getLast(locations).getDockerInfrastructure());
    List<DockerHostLocation> available = MutableList.copyOf(locations);
    boolean requireExclusive = config().get(REQUIRE_EXCLUSIVE);

    try {
        acquireMutex(entity.getApplicationId(), "Filtering locations for " + entity);
    } catch (InterruptedException ie) {
        Exceptions.propagate(ie); // Should never happen...
    }

    // Find hosts with entities from our application deployed there
    Iterable<DockerHostLocation> sameApplication = Iterables.filter(available,
            hasApplicationId(entity.getApplicationId()));

    // Check if hosts have any deployed entities that share a parent with the input entity
    Optional<DockerHostLocation> sameParent = Iterables.tryFind(sameApplication,
            childrenOf(entity.getParent()));
    if (sameParent.isPresent()) {
        LOG.debug("Returning {} (same parent) for {} placement", sameParent.get(), entity);
        return ImmutableList.copyOf(sameParent.asSet());
    }

    // Remove hosts if they have any entities from our application deployed there
    Iterables.removeIf(available, hasApplicationId(entity.getApplicationId()));
    if (requireExclusive) {
        Iterables.removeIf(available, nonEmpty());
    }
    LOG.debug("Returning {} for {} placement", Iterables.toString(available), entity);
    return available;
}

From source file:edu.umn.msi.tropix.storage.core.impl.StorageManagerImpl.java

public List<FileMetadata> getFileMetadata(List<String> ids, String gridId) {
    final ImmutableList.Builder<FileMetadata> fileMetadataList = ImmutableList.builder();
    LOG.debug("About to call canDownloadAll");
    if (!authorizationProvider.canDownloadAll(Iterables.toArray(ids, String.class), gridId)) {
        throw new RuntimeException("User " + gridId + " cannot access one of files " + Iterables.toString(ids));
    }/*from  w w  w  . j a v a 2s.c o  m*/
    LOG.debug("About to fetch file metadata");
    // TODO: Last bottle neck for SFTP server?
    for (final String id : ids) {
        fileMetadataList.add(getFileMetadata(id));
    }
    LOG.debug("Returning file metadata");
    return fileMetadataList.build();
}

From source file:com.google.devtools.build.skyframe.CycleInfo.java

@Override
public String toString() {
    return Iterables.toString(pathToCycle) + " -> " + Iterables.toString(cycle);
}