List of usage examples for com.google.common.collect ImmutableMap keySet
public ImmutableSet<K> keySet()
From source file:org.quickgeo.generate.Generate.java
License:asdf
public static void main(String[] args) throws Exception { Dataset ds = Dataset.generate();/*from w w w . j a va 2s. com*/ ImmutableMap<String, File> fileMap = Downloader.download(ds); ImmutableMap<String, InputStream> streamMap = convertToStreams(fileMap); deleteExisting(streamMap.keySet()); TemplateWriter.writeTemplates(streamMap); System.out.println("asdf"); }
From source file:com.facebook.buck.apple.AppleNativeIntegrationTestUtils.java
private static Optional<AppleSdk> anySdkForPlatform(final ApplePlatform platform, final ImmutableMap<AppleSdk, AppleSdkPaths> sdkPaths) { return sdkPaths.keySet().stream().filter(sdk -> sdk.getApplePlatform().equals(platform)).findFirst(); }
From source file:com.facebook.buck.android.ReplaceManifestPlaceholdersStep.java
@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))); }/*from w w w . ja va 2 s . co m*/ matcher.appendTail(sb); return sb.toString(); }
From source file:com.facebook.buck.cxx.toolchain.HeaderSymlinkTreeWithModuleMap.java
static Optional<String> getModuleName(ImmutableMap<Path, SourcePath> links) { if (links.size() > 0) { return Optional.of(links.keySet().iterator().next().getName(0).toString()); } else {//from w w w . j a va 2 s . c om return Optional.empty(); } }
From source file:org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase.java
public static void assertMapContains(Map<NodeId, Set<String>> expected, ImmutableMap<NodeId, Set<String>> actual) { for (NodeId k : actual.keySet()) { Assert.assertTrue(expected.containsKey(k)); assertCollectionEquals(expected.get(k), actual.get(k)); }/* ww w. j a va2 s . c o m*/ }
From source file:org.apache.flume.sink.kafka.KafkaSinkUtil.java
public static Properties getKafkaConfigProperties(Context context) { log.info("context={}", context.toString()); Properties props = new Properties(); ImmutableMap<String, String> contextMap = context.getParameters(); props.setProperty(serializedClazz, "kafka.serializer.StringEncoder"); for (String key : contextMap.keySet()) { if (!key.equals("type") && !key.equals("channel")) { props.setProperty(key, context.getString(key)); log.info("key={},value={}", key, context.getString(key)); }//from w w w. ja v a 2 s .c om } return props; }
From source file:google.registry.model.ofy.CommitLogCheckpoint.java
/** * Creates a CommitLogCheckpoint for the given wall time and bucket checkpoint times, specified * as a map from bucket ID to bucket commit timestamp. */// w w w .java 2 s .c om public static CommitLogCheckpoint create(DateTime checkpointTime, ImmutableMap<Integer, DateTime> bucketTimestamps) { checkArgument(Objects.equals(CommitLogBucket.getBucketIds().asList(), bucketTimestamps.keySet().asList()), "Bucket ids are incorrect: %s", bucketTimestamps.keySet()); CommitLogCheckpoint instance = new CommitLogCheckpoint(); instance.checkpointTime = checkpointTime.getMillis(); instance.bucketTimestamps = ImmutableList.copyOf(bucketTimestamps.values()); return instance; }
From source file:edu.buaa.satla.analysis.util.ImmutableMapMerger.java
/** * Join two maps taking the key into account, use {@code func} on duplicate values. * @param a input map/*from w w w. j a va 2 s. c o m*/ * @param b input map * @param func function to merge two values from different maps. * @return map containing the union of keys in {@code a} and {@code b}, which * contains the value from {@code a} if it contains only in {@code a}, value * from {@code b} if it is contained only in {@code b} and {@code func} * applied on value from {@code a} and a value from {@code b} otherwise. */ public static <K, V> ImmutableMap<K, V> merge(ImmutableMap<K, V> a, ImmutableMap<K, V> b, MergeFunc<K, V> func) { Set<K> allKeys = new HashSet<>(); allKeys.addAll(a.keySet()); allKeys.addAll(b.keySet()); ImmutableMap.Builder<K, V> builder = ImmutableMap.builder(); for (K key : allKeys) { if (a.containsKey(key) && !b.containsKey(key)) { builder.put(key, a.get(key)); } else if (!a.containsKey(key) && b.containsKey(key)) { builder.put(key, b.get(key)); } else { builder.put(key, func.apply(key, a.get(key), b.get(key))); } } return builder.build(); }
From source file:io.awacs.server.Configurations.java
public static List<String> exportServerAddr(Configuration configuration) { ImmutableMap<String, String> map = configuration.getSubProperties(SERVER_PREFIX + "."); Set<String> serverNames = map.keySet().stream().map(key -> key.substring(0, key.indexOf("."))) .collect(Collectors.toSet()); List<String> addrs = new ArrayList<>(serverNames.size()); addrs.addAll(serverNames.stream()//w w w.j a v a 2 s .co m .map(serverName -> map.getOrDefault(serverName + "." + TCP_BIND_HOST, DEFAULT_TCP_BIND_HOST) + ":" + map.getOrDefault(serverName + "." + TCP_BIND_PORT, DEFAULT_TCP_BIND_PORT)) .collect(Collectors.toList())); return addrs; }
From source file:com.facebook.buck.features.project.intellij.IjModuleGraph.java
private static void checkNamesAreUnique( ImmutableMap<IjProjectElement, ImmutableMap<IjProjectElement, DependencyType>> deps) { Set<String> names = new HashSet<>(); for (IjProjectElement element : deps.keySet()) { String name = element.getName(); Preconditions.checkArgument(!names.contains(name)); names.add(name);/*from w w w. ja v a2s. c om*/ } }