Package com.google.common.base

Examples of com.google.common.base.Joiner


   * Prints a set of modules to the manifest or bundle file.
   */
  @VisibleForTesting
  void printModuleGraphManifestOrBundleTo(JSModuleGraph graph,
      Appendable out, boolean isManifest) throws IOException {
    Joiner commas = Joiner.on(",");
    boolean requiresNewline = false;
    for (JSModule module : graph.getAllModules()) {
      if (requiresNewline) {
        out.append("\n");
      }

      if (isManifest) {
        // See CommandLineRunnerTest to see what the format of this
        // manifest looks like.
        String dependencies = commas.join(module.getSortedDependencyNames());
        out.append(
            String.format("{%s%s}\n",
                module.getName(),
                dependencies.isEmpty() ? "" : ":" + dependencies));
        printManifestTo(module.getInputs(), out);
View Full Code Here


      buf.append(' ').append(attr.getKey()).append("=\"")
         .append(attr.getValue()).append('\"');
    }
    buf.append(">\n");

    Joiner j = Joiner.on("\n");

    j.appendTo(buf, preloads);
    j.appendTo(buf, features.values());
    j.appendTo(buf, icons);
    j.appendTo(buf, locales.values());
    j.appendTo(buf, links.values());

    if (oauth != null) {
      buf.append(oauth).append('\n');
    }
    buf.append("</ModulePrefs>");
View Full Code Here

        "Resource request can not be null.");
    Set<String> dedupedRacks = new HashSet<String>();
    if (req.getRacks() != null) {
      dedupedRacks.addAll(req.getRacks());
      if(req.getRacks().size() != dedupedRacks.size()) {
        Joiner joiner = Joiner.on(',');
        LOG.warn("ContainerRequest has duplicate racks: "
            + joiner.join(req.getRacks()));
      }
    }
    Set<String> inferredRacks = resolveRacks(req.getNodes());
    inferredRacks.removeAll(dedupedRacks);

    // check that specific and non-specific requests cannot be mixed within a
    // priority
    checkLocalityRelaxationConflict(req.getPriority(), ANY_LIST,
        req.getRelaxLocality());
    // check that specific rack cannot be mixed with specific node within a
    // priority. If node and its rack are both specified then they must be
    // in the same request.
    // For explicitly requested racks, we set locality relaxation to true
    checkLocalityRelaxationConflict(req.getPriority(), dedupedRacks, true);
    checkLocalityRelaxationConflict(req.getPriority(), inferredRacks,
        req.getRelaxLocality());

    if (req.getNodes() != null) {
      HashSet<String> dedupedNodes = new HashSet<String>(req.getNodes());
      if(dedupedNodes.size() != req.getNodes().size()) {
        Joiner joiner = Joiner.on(',');
        LOG.warn("ContainerRequest has duplicate nodes: "
            + joiner.join(req.getNodes()));       
      }
      for (String node : dedupedNodes) {
        addResourceRequest(req.getPriority(), node, req.getCapability(), req,
            true);
      }
View Full Code Here

    } catch (IOException e) {
      System.err.println("Couldn't find file " + f.getName() + " to style: " + e.getMessage());
      return;
    }

    Joiner newlineJoiner = Joiner.on('\n');

    if (saveBackup) {
      File backup = new File(f.getAbsolutePath() + BACKUP_SUFFIX);
      try {
        Files.write(newlineJoiner.join(lines), backup, Charset.defaultCharset());
      } catch (IOException e) {
        System.err.println("Couldn't write backup " + backup.getName() + ": " + e.getMessage());
        return;
      }
    }

    try {
      Files.write(newlineJoiner.join(styleLines(lines)), f, Charset.defaultCharset());
    } catch (IOException e) {
      System.err.println("Couldn't write styled file " + f.getName() + ": " + e.getMessage());
      return;
    }
  }
View Full Code Here

   private void setAvailableVirtualDatacenters(final List<Integer> ids) {
      if (ids == null || ids.size() == 0) {
         target.setAvailableVirtualDatacenters("");
      } else {
         Joiner joiner = Joiner.on(",").skipNulls();
         target.setAvailableVirtualDatacenters(joiner.join(ids));
      }
   }
View Full Code Here

   * @param objects all the elements in the collection
   * @param transformer The transformer to be applied for each object
   * @return a String with all the elements in the collection joined with the token
   */
  public static <F> String join(String token, Collection<F> objects, Function<? super F, String> transformer) {
    Joiner joiner = Joiner.on(token);
    return joiner.join(Iterables.transform(objects, transformer));
  }
View Full Code Here

  public StringNumberGenerator(Random random) {
    this.random = random;
  }

  public String getString() {
    Joiner joiner = Joiner.on(' ');
    return joiner.join(getCombination());
  }
View Full Code Here

    Joiner joiner = Joiner.on(' ');
    return joiner.join(getCombination());
  }

  public String getPropertyName() {
    Joiner joiner = Joiner.on("");
    String[] combination = getCombination();
    return joiner.join(combination[0].toLowerCase(), combination[1]);
  }
View Full Code Here

        assertEquals("jointhemall", joiner.join("join", "them", "all"));
    }

    @Test
    public void testGuavaJoinerPerformance() throws Exception {
        Joiner joiner = Joiner.on("-separator-").skipNulls();

        for (int i = 0; i < PERFORMANCE_TEST_STEPS; i++) {
            joiner.join("big:table:id:string", "cell:id");
        }
    }
View Full Code Here

  private String getSection(String name, Map<String, String> mapping) {
    if(mapping.isEmpty()) {
      return "";
    }
    Joiner kvJoiner = Joiner.on(" = ");
    List<String> lines = Lists.newArrayList();
    lines.add("[" + name + "]");
    for(String key : mapping.keySet()) {
      lines.add(kvJoiner.join(key, mapping.get(key)));
    }
    return Joiner.on(NL).join(lines);
  }
View Full Code Here

TOP

Related Classes of com.google.common.base.Joiner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.