Search in sources :

Example 11 with Joiner

use of com.google.common.base.Joiner in project buck by facebook.

the class ReplaceManifestPlaceholdersStep method replacePlaceholders.

@VisibleForTesting
static String replacePlaceholders(String content, ImmutableMap<String, String> placeholders) {
    Iterable<String> escaped = Iterables.transform(placeholders.keySet(), Pattern::quote);
    Joiner joiner = Joiner.on("|");
    String patternString = Pattern.quote("${") + "(" + joiner.join(escaped) + ")" + Pattern.quote("}");
    Pattern pattern = Pattern.compile(patternString);
    Matcher matcher = pattern.matcher(content);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        matcher.appendReplacement(sb, placeholders.get(matcher.group(1)));
    }
    matcher.appendTail(sb);
    return sb.toString();
}
Also used : Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) Matcher(java.util.regex.Matcher) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with Joiner

use of com.google.common.base.Joiner in project killbill by killbill.

the class TestIntegrationBase method doCallAndCheckForCompletion.

private <T> T doCallAndCheckForCompletion(final Function<Void, T> f, final NextEvent... events) {
    final Joiner joiner = Joiner.on(", ");
    log.debug("            ************    STARTING BUS HANDLER CHECK : {} ********************", joiner.join(events));
    busHandler.pushExpectedEvents(events);
    final T result = f.apply(null);
    assertListenerStatus();
    log.debug("            ************    DONE WITH BUS HANDLER CHECK    ********************");
    return result;
}
Also used : Joiner(com.google.common.base.Joiner)

Example 13 with Joiner

use of com.google.common.base.Joiner in project hadoop by apache.

the class AMRMClientImpl method addContainerRequest.

@Override
public synchronized void addContainerRequest(T req) {
    Preconditions.checkArgument(req != null, "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.getAllocationRequestId(), 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.getAllocationRequestId(), req.getPriority(), dedupedRacks, true);
    checkLocalityRelaxationConflict(req.getAllocationRequestId(), req.getPriority(), inferredRacks, req.getRelaxLocality());
    // check if the node label expression specified is valid
    checkNodeLabelExpression(req);
    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.getExecutionTypeRequest(), req.getCapability(), req, true, req.getNodeLabelExpression());
        }
    }
    for (String rack : dedupedRacks) {
        addResourceRequest(req.getPriority(), rack, req.getExecutionTypeRequest(), req.getCapability(), req, true, req.getNodeLabelExpression());
    }
    // corresponding rack
    for (String rack : inferredRacks) {
        addResourceRequest(req.getPriority(), rack, req.getExecutionTypeRequest(), req.getCapability(), req, req.getRelaxLocality(), req.getNodeLabelExpression());
    }
    // Off-switch
    addResourceRequest(req.getPriority(), ResourceRequest.ANY, req.getExecutionTypeRequest(), req.getCapability(), req, req.getRelaxLocality(), req.getNodeLabelExpression());
}
Also used : Joiner(com.google.common.base.Joiner) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 14 with Joiner

use of com.google.common.base.Joiner in project intellij-community by JetBrains.

the class PyTestCase method compareStringSets.

/**
   * Compares sets with string sorting them and displaying one-per-line to make comparision easier
   *
   * @param message  message to display in case of error
   * @param actual   actual set
   * @param expected expected set
   */
protected static void compareStringSets(@NotNull final String message, @NotNull final Set<String> actual, @NotNull final Set<String> expected) {
    final Joiner joiner = Joiner.on("\n");
    Assert.assertEquals(message, joiner.join(new TreeSet<>(actual)), joiner.join(new TreeSet<>(expected)));
}
Also used : Joiner(com.google.common.base.Joiner)

Example 15 with Joiner

use of com.google.common.base.Joiner in project smali by JesusFreke.

the class ClassPathResolver method loadLocalOrDeviceBootClassPathEntry.

private void loadLocalOrDeviceBootClassPathEntry(@Nonnull String entry) throws IOException, NoDexException, NotFoundException {
    // first, see if the entry is a valid local path
    if (loadLocalClassPathEntry(entry)) {
        return;
    }
    // It's not a local path, so let's try to resolve it as a device path, relative to one of the provided
    // directories
    List<String> pathComponents = splitDevicePath(entry);
    Joiner pathJoiner = Joiner.on(File.pathSeparatorChar);
    for (String directory : classPathDirs) {
        File directoryFile = new File(directory);
        if (!directoryFile.exists()) {
            continue;
        }
        for (int i = 0; i < pathComponents.size(); i++) {
            String partialPath = pathJoiner.join(pathComponents.subList(i, pathComponents.size()));
            File entryFile = new File(directoryFile, partialPath);
            if (entryFile.exists() && entryFile.isFile()) {
                loadEntry(entryFile, true);
                return;
            }
        }
    }
    throw new NotFoundException("Could not find classpath entry %s", entry);
}
Also used : Joiner(com.google.common.base.Joiner) DexBackedDexFile(org.jf.dexlib2.dexbacked.DexBackedDexFile) OatFile(org.jf.dexlib2.dexbacked.OatFile) DexBackedOdexFile(org.jf.dexlib2.dexbacked.DexBackedOdexFile) File(java.io.File) DexFile(org.jf.dexlib2.iface.DexFile) OatDexFile(org.jf.dexlib2.dexbacked.OatFile.OatDexFile) MultiDexFile(org.jf.dexlib2.iface.MultiDexContainer.MultiDexFile)

Aggregations

Joiner (com.google.common.base.Joiner)47 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)6 IOException (java.io.IOException)5 Map (java.util.Map)4 BufferedWriter (java.io.BufferedWriter)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 ResultSet (com.google.cloud.spanner.ResultSet)2 Statement (com.google.cloud.spanner.Statement)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 DBException (com.yahoo.ycsb.DBException)2 File (java.io.File)2 URI (java.net.URI)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)2 FileLineDifferenceIterator (org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1