Package com.google.common.base

Examples of com.google.common.base.Joiner


     
      for(String durationBin : durationBins) {
        durationValues.add(durationDistribution.count(durationBin));
      }

      Joiner joiner = Joiner.on(',');
      return joiner.join(durationValues);
    }
View Full Code Here


        distribution.add(String.format("%s:%d", bin, durationDistribution.count(bin)));
      }
     
    }
   
    Joiner joiner = Joiner.on(separator);
    return joiner.join(distribution);
  }
View Full Code Here

          }
        }, ptf.tableOf(ptf.strings(), ptf.pairs(ptf.ints(), ptf.ints())));
    Iterable<String> lines = SecondarySort.sortAndApply(in, new MapFn<Pair<String, Iterable<Pair<Integer, Integer>>>, String>() {
      @Override
      public String map(Pair<String, Iterable<Pair<Integer, Integer>>> input) {
        Joiner j = Joiner.on(',');
        return j.join(input.first(), j.join(input.second()));
      }
    }, ptf.strings()).materialize();
    assertEquals(ImmutableList.of("one,[-5,10],[1,1],[2,-3]", "three,[0,-1]", "two,[1,7],[2,6],[4,5]"),
        ImmutableList.copyOf(lines));
    p.done();
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

   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

   * 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.getAllModulesInDependencyOrder()) {
      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

        return from.getPath().substring( dir.getPath().length() + 1 );
      }
    } ) );
    Collections.sort( names );

    Joiner joiner = Joiner.on( "\n" );
    return joiner.join( names );
  }
View Full Code Here

    }

    private static <T> void assertListEquals(List<T> actual, List<T> expected)
    {
        if (actual.size() != expected.size()) {
            Joiner joiner = Joiner.on("\n    ");
            throw new AssertionError(format(
                    "Lists not equal%nActual [%s]:%n    %s%nExpected [%s]:%n    %s%n",
                    actual.size(), joiner.join(actual),
                    expected.size(), joiner.join(expected)));
        }
        assertEquals(actual, expected);
    }
View Full Code Here

      }
      if (allContain) {
        commons.add(word);
      }
    }
    Joiner joiner = Joiner.on("/").skipNulls();
    return "/" + joiner.join(commons);
  }
View Full Code Here

  public static Map<String,String> configureForKeyStore(File keyStoreFile,
      File keyStorePasswordFile, Map<String, File> keyAliasPassword)
          throws Exception {
    Map<String, String> context = Maps.newHashMap();
    List<String> keys = Lists.newArrayList();
    Joiner joiner = Joiner.on(".");
    for(String alias : keyAliasPassword.keySet()) {
      File passwordFile = keyAliasPassword.get(alias);
      if(passwordFile == null) {
        keys.add(alias);
      } else {
        String propertyName = joiner.join(EncryptionConfiguration.KEY_PROVIDER,
            EncryptionConfiguration.JCE_FILE_KEYS, alias,
            EncryptionConfiguration.JCE_FILE_KEY_PASSWORD_FILE);
        keys.add(alias);
        context.put(propertyName, passwordFile.getAbsolutePath());
      }
    }
    context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
        EncryptionConfiguration.JCE_FILE_KEY_STORE_FILE),
        keyStoreFile.getAbsolutePath());
    if(keyStorePasswordFile != null) {
      context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
          EncryptionConfiguration.JCE_FILE_KEY_STORE_PASSWORD_FILE),
          keyStorePasswordFile.getAbsolutePath());
    }
    context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER,
        EncryptionConfiguration.JCE_FILE_KEYS),
        Joiner.on(" ").join(keys));
    return context;
  }
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.