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();
}
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;
}
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());
}
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)));
}
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);
}
Aggregations