List of usage examples for com.google.common.collect ImmutableMap entrySet
public final ImmutableSet<Entry<K, V>> entrySet()
From source file:com.facebook.buck.intellij.ideabuck.environment.EnvironmentFilter.java
/** * Given a map (environment variable name: environment variable * value) pairs, returns a map without the variables which we should * not pass to child processes (buck.py, javac, etc.) * * Keeping the environment map clean helps us avoid jettisoning the * parser cache, as we have to rebuild it any time the environment * changes./* w ww . ja v a2 s . c o m*/ */ public static ImmutableMap<String, String> filteredEnvironment(ImmutableMap<String, String> environment, Platform platform) { ImmutableMap.Builder<String, String> filteredEnvironmentBuilder = ImmutableMap.builder(); for (Map.Entry<String, String> envEntry : environment.entrySet()) { String key = envEntry.getKey(); if (!ENV_TO_REMOVE.contains(key)) { if (platform == Platform.WINDOWS) { // Windows environment variables are case insensitive. While an ImmutableMap will throw // if we get duplicate key, we don't have to worry about this for Windows. filteredEnvironmentBuilder.put(key.toUpperCase(Locale.US), envEntry.getValue()); } else { filteredEnvironmentBuilder.put(envEntry); } } } return filteredEnvironmentBuilder.build(); }
From source file:ealvatag.tag.id3.ID3Mapping.java
private static ImmutableMap<String, String> makeConvertV23ToV22() { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); final ImmutableMap<String, String> convertv22Tov23 = getConvertv22Tov23(); for (Map.Entry<String, String> entry : convertv22Tov23.entrySet()) { builder.put(entry.getValue(), entry.getKey()); }/*from w ww. j a v a2s .c o m*/ //This one way translation allows us to convert XSOT to TST, but in the other direction gets converted to TSOT builder.put(ID3v23Frames.FRAME_ID_V3_TITLE_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_TITLE_SORT_ORDER_ITUNES) .put(ID3v23Frames.FRAME_ID_V3_ARTIST_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_ARTIST_SORT_ORDER_ITUNES) .put(ID3v23Frames.FRAME_ID_V3_ALBUM_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_ALBUM_SORT_ORDER_ITUNES); return builder.build(); }
From source file:org.knime.ext.textprocessing.nodes.tokenization.TokenizerFactoryRegistry.java
/** * @return Returns m_tokenizerMap as a String array, so it can be used for the {@code ComboFieldEditor} in the * {@code TextprocessingPreferenceInitializer} class. * @since 3.3/*from w w w .ja v a2 s. com*/ */ public static String[][] getMapAsStringArray() { ImmutableMap<String, TokenizerFactory> map = getTokenizerFactoryMap(); String[][] array = new String[map.size()][2]; int counter = 0; for (ImmutableMap.Entry<String, TokenizerFactory> entry : map.entrySet()) { array[counter][0] = entry.getKey(); array[counter][1] = entry.getKey(); counter++; } return array; }
From source file:org.glowroot.agent.plugin.servlet.Beans.java
static Map<String, String> propertiesAsText(Object obj) { Map<String, String> properties = Maps.newHashMap(); ImmutableMap<String, Method> allGettersForObj = wildcardGetters.getUnchecked(obj.getClass()); for (Entry<String, Method> entry : allGettersForObj.entrySet()) { try {//from w w w .j a va 2 s . co m Object value = entry.getValue().invoke(obj); if (value != null) { properties.put(entry.getKey(), value.toString()); } } catch (Exception e) { // log exception at debug level logger.debug(e.getMessage(), e); properties.put(entry.getKey(), "<could not access>"); } } return properties; }
From source file:org.glowroot.plugin.servlet.Beans.java
public static Map<String, String> propertiesAsText(Object obj) { Map<String, String> properties = Maps.newHashMap(); ImmutableMap<String, Method> allGettersForObj = wildcardGetters.getUnchecked(obj.getClass()); for (Entry<String, Method> entry : allGettersForObj.entrySet()) { try {//from w w w . j a va 2 s . c o m Object value = entry.getValue().invoke(obj); if (value != null) { properties.put(entry.getKey(), value.toString()); } } catch (Exception e) { // log exception at debug level logger.debug(e.getMessage(), e); properties.put(entry.getKey(), "<could not access>"); } } return properties; }
From source file:com.facebook.buck.cxx.CxxCompilableEnhancer.java
/** * Resolve the map of names to SourcePaths to a map of names to CxxSource objects. *//*from w w w. ja v a2 s . c o m*/ public static ImmutableMap<String, CxxSource> resolveCxxSources(ImmutableMap<String, SourceWithFlags> sources) { ImmutableMap.Builder<String, CxxSource> cxxSources = ImmutableMap.builder(); // For each entry in the input C/C++ source, build a CxxSource object to wrap // it's name, input path, and output object file path. for (ImmutableMap.Entry<String, SourceWithFlags> ent : sources.entrySet()) { String extension = Files.getFileExtension(ent.getKey()); Optional<CxxSource.Type> type = CxxSource.Type.fromExtension(extension); if (!type.isPresent()) { throw new HumanReadableException("invalid extension \"%s\": %s", extension, ent.getKey()); } cxxSources.put(ent.getKey(), CxxSource.of(type.get(), ent.getValue().getSourcePath(), ent.getValue().getFlags())); } return cxxSources.build(); }
From source file:com.foudroyantfactotum.mod.fousarchive.midi.MidiDetails.java
public static MidiDetails fromMap(ImmutableMap<String, String> map) { final String[] elem = new String[tags.length + 1]; for (Map.Entry<String, String> entry : map.entrySet()) if (ctt.containsKey(entry.getKey())) elem[ctt.get(entry.getKey())] = entry.getValue(); if (elem[0] == null || elem[7] == null) return null; return new MidiDetails(elem, Long.parseLong(map.get("maxTicks"))); }
From source file:org.grycap.gpf4med.Gpf4MedService.java
/** * Creates a Grizzly HTTP server exposing JAX-RS resources defined in this service. * @return Grizzly HTTP server./*from w w w.java 2s . c o m*/ */ private static HttpServer createServer(final String baseUri) { HttpServer server = null; try { // scan for connectors final Set<Class<?>> classSet = newLinkedHashSet(); final ImmutableMap<String, GraphConnector> connectors = GraphConnectorManager.INSTANCE.listConnectors(); if (connectors != null && !connectors.isEmpty()) { classSet.addAll(transform(connectors.entrySet(), new Function<Map.Entry<String, GraphConnector>, Class<?>>() { @Override public Class<?> apply(final Entry<String, GraphConnector> entry) { return entry.getValue().restResourceImplementation(); } })); } // create a resource configuration that scans for JAX-RS resources and providers final ResourceConfig resourceConfig = ResourceConfig.forApplication(new Application() { @Override public Set<Class<?>> getClasses() { final Set<Class<?>> classes = newHashSet(); classes.add(Gpf4MedResourceImpl.class); return classes; } }).register(MoxyJsonFeature.class); if (!classSet.isEmpty()) { resourceConfig.registerClasses(classSet); } // create a non-started-yet HttpServer instance server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUri), resourceConfig, false); // serve static HTTP resources from file-system final File htdocsDir = ConfigurationManager.INSTANCE.getHtdocsDir(); if (htdocsDir != null && htdocsDir.isDirectory() && htdocsDir.canRead()) { final StaticHttpHandler staticHttpHandler = new StaticHttpHandler(htdocsDir.getCanonicalPath()); server.getServerConfiguration().addHttpHandler(staticHttpHandler, "/"); } // apply any optional configuration to the HttpServer instance and start the service final TCPNIOTransport transport = server.getListener("grizzly").getTransport(); transport.setTcpNoDelay(true); } catch (Exception e) { server = null; LOGGER.error("Failed to create HTTP server", e); } return server; }
From source file:google.registry.keyring.kms.KmsUpdater.java
/** * Persists encrypted secrets to Datastore as {@link KmsSecretRevision} entities and makes them * primary. {@link KmsSecret} entities point to the latest {@link KmsSecretRevision}. * * <p>The changes are committed transactionally; if an error occurs, all existing {@link * KmsSecretRevision} entities will remain primary. *//* w w w . j a va 2 s . co m*/ private static void persistEncryptedValues(final ImmutableMap<String, EncryptResponse> encryptedValues) { ofy().transact(new VoidWork() { @Override public void vrun() { for (Map.Entry<String, EncryptResponse> entry : encryptedValues.entrySet()) { String secretName = entry.getKey(); EncryptResponse revisionData = entry.getValue(); KmsSecretRevision secretRevision = new KmsSecretRevision.Builder() .setEncryptedValue(revisionData.ciphertext()) .setKmsCryptoKeyVersionName(revisionData.cryptoKeyVersionName()).setParent(secretName) .build(); ofy().save().entities(secretRevision, KmsSecret.create(secretName, secretRevision)); } } }); }
From source file:com.spectralogic.ds3autogen.converters.UpdateElementsConverter.java
/** * Updates all Ds3Type's Ds3Elements to properly denote nullability or exclusion *//*w ww . j av a 2 s.c om*/ protected static ImmutableMap<String, Ds3Type> updateElementsInTypeMap( final ImmutableMap<String, Ds3Type> typeMap) { if (isEmpty(typeMap)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3Type> builder = ImmutableMap.builder(); for (final Map.Entry<String, Ds3Type> entry : typeMap.entrySet()) { builder.put(entry.getKey(), updateElementsInType(entry.getValue())); } return builder.build(); }