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

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

Introduction

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

Prototype

public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:org.ow2.mind.adl.OptimInstanceSourceGeneratorDispatcher.java

@Override
protected Iterable<? extends VoidVisitor<InstancesDescriptor>> getVisitorsItf(
        final Map<Object, Object> context) {
    return Iterables.concat(visitorsItf,
            VisitorExtensionHelper.getInstanceSourceGeneratorExtensions(pluginManager, context));
}

From source file:co.cask.cdap.logging.appender.LoggingContextMDC.java

LoggingContextMDC(LoggingContext loggingContext, Map<String, String> eventMDC) {
    this.systemTags = loggingContext.getSystemTagsAsString();
    this.eventMDC = eventMDC;
    this.entryIterable = Iterables.concat(systemTags.entrySet(),
            Iterables.filter(eventMDC.entrySet(), new Predicate<Entry<String, String>>() {
                @Override//from  w w w. j a va2 s .  c o  m
                public boolean apply(Entry<String, String> entry) {
                    return !systemTags.containsKey(entry.getKey());
                }
            }));
}

From source file:org.ow2.mind.adl.OptimDefinitionSourceGeneratorDispatcher.java

@Override
protected Iterable<? extends VoidVisitor<Definition>> getVisitorsItf(final Map<Object, Object> context) {
    return Iterables.concat(visitorsItf,
            VisitorExtensionHelper.getDefinitionSourceGeneratorExtensions(pluginManager, context));
}

From source file:co.cask.cdap.hive.ExploreUtils.java

/**
 * Builds a class loader with the class path provided.
 *///  w  ww . jav  a  2  s.co  m
public static synchronized ClassLoader getExploreClassloader() {
    if (exploreClassLoader != null) {
        return exploreClassLoader;
    }

    // EXPLORE_CLASSPATH and EXPLORE_CONF_FILES will be defined in startup scripts if Hive is installed.
    String exploreClassPathStr = System.getProperty(Constants.Explore.EXPLORE_CLASSPATH);
    LOG.debug("Explore classpath = {}", exploreClassPathStr);
    if (exploreClassPathStr == null) {
        throw new RuntimeException("System property " + Constants.Explore.EXPLORE_CLASSPATH + " is not set.");
    }

    String exploreConfPathStr = System.getProperty(Constants.Explore.EXPLORE_CONF_FILES);
    LOG.debug("Explore confPath = {}", exploreConfPathStr);
    if (exploreConfPathStr == null) {
        throw new RuntimeException("System property " + Constants.Explore.EXPLORE_CONF_FILES + " is not set.");
    }

    Iterable<File> hiveClassPath = getClassPathJarsFiles(exploreClassPathStr);
    Iterable<File> hiveConfFiles = getClassPathJarsFiles(exploreConfPathStr);
    ImmutableList.Builder<URL> builder = ImmutableList.builder();
    for (File file : Iterables.concat(hiveClassPath, hiveConfFiles)) {
        try {
            if (file.getName().matches(".*\\.xml")) {
                builder.add(file.getParentFile().toURI().toURL());
            } else {
                builder.add(file.toURI().toURL());
            }
        } catch (MalformedURLException e) {
            LOG.error("Jar URL is malformed", e);
            throw Throwables.propagate(e);
        }
    }
    exploreClassLoader = new URLClassLoader(Iterables.toArray(builder.build(), URL.class),
            ClassLoader.getSystemClassLoader());
    return exploreClassLoader;
}

From source file:c5db.log.EntryEncodingUtil.java

/**
 * Serialize a protostuff message object, prefixed with message length, and suffixed with a 4-byte CRC.
 *
 * @param schema  Protostuff message schema
 * @param message Object to serialize//w  ww . j  a v  a 2 s .co m
 * @param <T>     Message type
 * @return A list of ByteBuffers containing a varInt length, followed by the message, followed by a 4-byte CRC.
 */
public static <T> List<ByteBuffer> encodeWithLengthAndCrc(Schema<T> schema, T message) {
    final LinkBuffer messageBuf = new LinkBuffer();
    final LowCopyProtobufOutput lcpo = new LowCopyProtobufOutput(messageBuf);

    try {
        schema.writeTo(lcpo, message);

        final int length = Ints.checkedCast(lcpo.buffer.size());
        final LinkBuffer lengthBuf = new LinkBuffer().writeVarInt32(length);

        return appendCrcToBufferList(
                Lists.newArrayList(Iterables.concat(lengthBuf.finish(), messageBuf.finish())));
    } catch (IOException e) {
        // This method performs no IO, so it should not actually be possible for an IOException to be thrown.
        // But just in case...
        throw new RuntimeException(e);
    }
}

From source file:com.matthewmitchell.peercoinj.crypto.HDUtils.java

public static String formatPath(List<ChildNumber> path) {
    return PATH_JOINER.join(Iterables.concat(Collections.singleton("M"), path));
}

From source file:com.streamreduce.util.ConnectionUtils.java

/**
 * Returns an iterable of all {@link ConnectionProvider}, regardless of type.
 *
 * @return an iterable of supported provider objects, regardless of type
 *//*from w w  w .  j a  v  a 2  s . co m*/
public static Iterable<? extends ConnectionProvider> getAllProviders() {
    Iterable<? extends ConnectionProvider> allProviders = null;

    for (String providerType : PROVIDER_MAP.keySet()) {
        Iterable<? extends ConnectionProvider> providers = getSupportedProviders(providerType);

        if (allProviders == null) {
            allProviders = providers;
        } else {
            allProviders = Iterables.concat(allProviders, providers);
        }
    }

    return allProviders;
}

From source file:org.trancecode.collection.TcIterables.java

public static <T> Iterable<T> append(final Iterable<T> iterable, final T element) {
    return Iterables.concat(iterable, ImmutableList.of(element));
}

From source file:org.auraframework.impl.css.parser.FlavoredStyleParser.java

@Override
public FlavoredStyleDef parse(DefDescriptor<FlavoredStyleDef> descriptor, Source<FlavoredStyleDef> source)
        throws QuickFixException {

    ParserResult result = CssPreprocessor.initial().source(source.getContents())
            .resourceName(source.getSystemId())
            .allowedConditions(//w  ww.jav a  2 s .c o  m
                    Iterables.concat(ALLOWED_CONDITIONS, Aura.getStyleAdapter().getExtraAllowedConditions()))
            .tokens(descriptor).flavors(descriptor).parse();

    FlavoredStyleDefImpl.Builder builder = new FlavoredStyleDefImpl.Builder();
    builder.setDescriptor(descriptor);
    builder.setLocation(source.getSystemId(), source.getLastModified());
    builder.setOwnHash(source.getHash());
    builder.setContent(result.content());
    builder.setTokenExpressions(result.expressions());
    builder.setFlavorAnnotations(result.flavorAnnotations());

    return builder.build();
}

From source file:com.oculusinfo.tile.init.providers.StandardPyramidIOFactoryProvider.java

/**
 * Concatenates two string lists together.
 * @return If either of the input lists are null, then the other is returned, othwerise
 * a new list is created that contains both lists.
 *//*from  www  .j av a 2  s.co  m*/
private static List<String> getMergedPath(List<String> path1, List<String> path2) {
    if (path1 == null)
        return path2;
    if (path2 == null)
        return path1;
    return Lists.newArrayList(Iterables.concat(path1, path2));
}