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

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

Introduction

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

Prototype

public static <E> ImmutableList<E> of(E e1, E e2) 

Source Link

Usage

From source file:com.google.devtools.build.docgen.BlazeRuleHelpPrinter.java

/**
 * Returns the documentation of the given rule to be printed on the console.
 *//*from   w  w  w  .j a v  a2s.  co  m*/
public static String getRuleDoc(String ruleName, ConfiguredRuleClassProvider provider) {
    if (ruleDocMap == null) {
        try {
            BuildDocCollector collector = new BuildDocCollector(provider, false);
            Map<String, RuleDocumentation> ruleDocs = collector.collect(ImmutableList
                    .of("java/com/google/devtools/build/lib/view", "java/com/google/devtools/build/lib/rules"),
                    null);
            ruleDocMap = new HashMap<>();
            for (RuleDocumentation ruleDoc : ruleDocs.values()) {
                ruleDocMap.put(ruleDoc.getRuleName(), ruleDoc);
            }
        } catch (BuildEncyclopediaDocException e) {
            return e.getErrorMsg();
        } catch (IOException e) {
            return e.getMessage();
        }
    }
    // Every rule should be documented and this method should be called only
    // for existing rules (a check is performed in HelpCommand).
    Preconditions.checkState(ruleDocMap.containsKey(ruleName),
            String.format("ERROR: Documentation of rule %s does not exist.", ruleName));
    return "Rule " + ruleName + ":" + ruleDocMap.get(ruleName).getCommandLineDocumentation() + "\n";
}

From source file:com.querydsl.core.types.expr.DateOperation.java

public static <D extends Comparable<?>> DateExpression<D> create(Class<D> type, Operator<? super D> op,
        Expression<?> one, Expression<?> two) {
    return new DateOperation<D>(type, op, ImmutableList.of(one, two));
}

From source file:com.mysema.query.spatial.jts.JTSGeometryOperation.java

public static <D extends Geometry> JTSGeometryOperation<D> create(Class<D> type, Operator<? super D> op,
        Expression<?> one, Expression<?> two) {
    return new JTSGeometryOperation<D>(type, op, ImmutableList.of(one, two));
}

From source file:org.apache.aurora.scheduler.offers.Offers.java

public static Offer makeOffer(String offerId, String hostName) {
    return Offer.newBuilder().setId(OfferID.newBuilder().setValue(offerId))
            .setFrameworkId(FrameworkID.newBuilder().setValue("framework_id"))
            .setAgentId(AgentID.newBuilder().setValue("slave_id-" + offerId)).setHostname(hostName)
            .addAllResources(ImmutableList.of(mesosScalar(ResourceType.CPUS, 10),
                    mesosScalar(ResourceType.RAM_MB, 1024)))
            .build();/*w  ww. j a v  a2s  .  c  o m*/
}

From source file:com.querydsl.core.types.expr.DateTimeOperation.java

public static <D extends Comparable<?>> DateTimeExpression<D> create(Class<D> type, Operator<? super D> op,
        Expression<?> one, Expression<?> two) {
    return new DateTimeOperation<D>(type, op, ImmutableList.of(one, two));
}

From source file:controllers.UseCase3.java

/**
 * In this example even though the ModelDescription has two slow service call invocations we can still
 * flush the response of MiniSrp pagelet stream via injecting div content into DOM.
 */// ww w . j  a  va 2 s. c om
public static Result index(final int vehicleId) {
    final HtmlStream modelDesc = ModelDescPagelet.stream(vehicleId, 4, 2, false);
    final HtmlStream miniSrp = MiniSrpPagelet.stream(vehicleId, 0, false);

    final HtmlStream modelDescPagelet = Pagelet.renderStream(modelDesc, "modelDescP");
    final HtmlStream miniSrpPagelet = Pagelet.renderStream(miniSrp, "miniSrpP");

    final HtmlStream bigPipe = HtmlStream.interleave(ImmutableList.of(modelDescPagelet, miniSrpPagelet));

    final HtmlStream out = (HtmlStream) views.stream.usecase3.render(HtmlStream.empty(), HtmlStream.empty(),
            bigPipe);

    return ok(out.toChunks());
}

From source file:com.mysema.query.spatial.jts.JTSLineStringOperation.java

public static <D extends LineString> JTSLineStringOperation<D> create(Class<D> type, Operator<? super D> op,
        Expression<?> one, Expression<?> two) {
    return new JTSLineStringOperation<D>(type, op, ImmutableList.of(one, two));
}

From source file:io.v.impl.google.naming.NamingUtil.java

/**
 * Takes an object name and returns the server address and the name relative to the server.
 * <p>//from   w  w w. ja  v a  2s .  com
 * The name parameter may be a rooted name or a relative name; an empty string
 * address is returned for the latter case.
 * <p>
 * The returned address may be in endpoint format or {@code host:port} format.
 * <p>
 * The returned list is guaranteed to contain exactly two entries: the server address and
 * the name relative to the server.
 *
 * @param  name name from which the server address and relative name are extracted
 * @return      a list containing exactly two entries: the server address and
 *              the name relative to the server
 */
public static List<String> splitAddressName(String name) {
    name = clean(name);
    if (!isRooted(name)) {
        return ImmutableList.of("", name);
    }
    name = name.substring(1, name.length()); // trim the beginning "/"
    if (name.isEmpty()) {
        return ImmutableList.of("", "");
    }
    // Could have used regular expressions, but that makes this function
    // 10x slower as per the benchmark.
    if (name.startsWith("@")) { // <endpoint>/<suffix>
        List<String> parts = splitInTwo(name, "@@/");
        String addr = parts.get(0), suffix = parts.get(1);
        if (!suffix.isEmpty()) { // The trailing "@@" was stripped, restore it
            addr += "@@";
        }
        return ImmutableList.of(addr, suffix);
    }
    if (name.startsWith("(")) { // (blessing)@host:[port]/suffix
        String tmp = splitInTwo(name, ")@").get(1);
        String suffix = splitInTwo(tmp, "/").get(1);
        String addr = trimSuffix(name, "/" + suffix);
        if (addr.endsWith("/" + suffix)) {
            addr = addr.substring(0, addr.length() - suffix.length() - 1);
        }
        return ImmutableList.of(addr, suffix);
    }
    // host:[port]/suffix
    List<String> parts = splitInTwo(name, "/");
    return ImmutableList.of(parts.get(0), parts.get(1));
}

From source file:com.mysema.query.types.OperationImpl.java

public static <RT> Operation<RT> create(Class<? extends RT> type, Operator<? super RT> operator,
        Expression<?> one, Expression<?> two) {
    return new OperationImpl<RT>(type, operator, ImmutableList.of(one, two));
}

From source file:co.cask.cdap.explore.service.FileWriterHelper.java

/**
 * Generate an Avro file of schema (key String, value String) containing the records ("<prefix>i", "#i")
 * for start <= i < end. The file is written using the passed-in output stream.
 */// ww  w.  j  av a  2  s . c  o  m
public static void generateAvroFile(OutputStream out, String prefix, int start, int end) throws IOException {
    Schema schema = Schema.createRecord("kv", null, null, false);
    schema.setFields(ImmutableList.of(new Schema.Field("key", Schema.create(Schema.Type.STRING), null, null),
            new Schema.Field("value", Schema.create(Schema.Type.STRING), null, null)));

    DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(schema);
    DataFileWriter<GenericRecord> dataFileWriter = new DataFileWriter<>(datumWriter);
    dataFileWriter.create(schema, out);
    try {
        for (int i = start; i < end; i++) {
            GenericRecord kv = new GenericData.Record(schema);
            kv.put("key", prefix + i);
            kv.put("value", "#" + i);
            dataFileWriter.append(kv);
        }
    } finally {
        Closeables.closeQuietly(dataFileWriter);
        Closeables.closeQuietly(out);
    }
}