List of usage examples for com.google.common.collect Maps fromProperties
@GwtIncompatible("java.util.Properties") public static ImmutableMap<String, String> fromProperties(Properties properties)
From source file:eu.eidas.auth.commons.EIDASUtil.java
@SuppressWarnings("CollectionDeclaredAsConcreteClass") @Nonnull//ww w . j a v a2 s . c om static ImmutableMap<String, String> immutableMap(@Nullable Properties properties) { if (null == properties || properties.isEmpty()) { return ImmutableMap.of(); } return Maps.fromProperties(properties); }
From source file:com.xemantic.tadedon.guice.configuration.GuiceConfigurations.java
public static void bindConfiguration(Binder binder, String confName, Configuration configuration) { int dotIndex = confName.lastIndexOf("."); String confKey = confName.substring(0, dotIndex) + "Config"; binder.bind(Configuration.class).annotatedWith(Names.named(confKey)).toInstance(configuration); if (configuration instanceof PropertiesConfiguration) { binder.bind(PropertiesConfiguration.class).annotatedWith(Names.named(confKey)) .toInstance((PropertiesConfiguration) configuration); Properties properties = Configurations.toProperties(configuration); binder.bind(Properties.class).annotatedWith(Names.named(confKey)).toInstance(properties); binder.bind(new TypeLiteral<Map<String, String>>() { }).annotatedWith(Names.named(confKey)).toInstance(Maps.fromProperties(properties)); } else if (configuration instanceof XMLConfiguration) { binder.bind(XMLConfiguration.class).annotatedWith(Names.named(confKey)) .toInstance((XMLConfiguration) configuration); }// w w w . j a v a2s . c om }
From source file:org.killbill.billing.plugin.simpletax.plumbing.SimpleTaxConfigurationHandler.java
@Override protected SimpleTaxConfig createConfigurable(Properties pluginConfig) { Map<String, String> props = Maps.fromProperties(pluginConfig); return new SimpleTaxConfig(props, logService); }
From source file:org.sonar.batch.bootstrapper.Batch.java
private Batch(Builder builder) { components = Lists.newArrayList();//from w w w.j a va 2s . c om components.addAll(builder.components); components.add(builder.environment); if (builder.globalProperties != null) { globalProperties.putAll(builder.globalProperties); } else { // For backward compatibility, previously all properties were set in root project globalProperties.putAll(Maps.fromProperties(builder.projectReactor.getRoot().getProperties())); } this.taskCommand = builder.taskCommand; projectReactor = builder.projectReactor; if (builder.isEnableLoggingConfiguration()) { logging = LoggingConfiguration.create().setProperties(globalProperties); } }
From source file:org.basepom.mojo.propertyhelper.beans.MacroDefinition.java
public Map<String, String> getProperties() { return ImmutableMap.copyOf(Maps.fromProperties(properties)); }
From source file:org.pentaho.big.data.impl.shim.sqoop.SqoopServiceImpl.java
@Override public int runTool(List<String> args, Properties properties) { Configuration configuration = hadoopShim.createConfiguration(); for (Map.Entry<String, String> entry : Maps.fromProperties(properties).entrySet()) { configuration.set(entry.getKey(), entry.getValue()); }/*from w ww .j a va2s .c o m*/ try { // Make sure Sqoop throws exceptions instead of returning a status of 1 System.setProperty(SQOOP_THROW_ON_ERROR, Boolean.toString(true)); configureShim(configuration); return sqoopShim.runTool(args.toArray(new String[args.size()]), configuration); } catch (Exception e) { LOGGER.error("Error executing sqoop", e); return 1; } }
From source file:io.druid.server.StatusResource.java
@GET @Path("/properties") @ResourceFilters(ConfigResourceFilter.class) @Produces(MediaType.APPLICATION_JSON)/*from w w w. j a v a2 s. c om*/ public Map<String, String> getProperties() { Map<String, String> allProperties = Maps.fromProperties(properties); Set<String> hidderProperties = druidServerConfig.getHiddenProperties(); return Maps.filterEntries(allProperties, (entry) -> !hidderProperties.contains(entry.getKey())); }
From source file:org.zalando.stups.spring.boot.actuator.ExtInfoEndpointConfiguration.java
@Bean public InfoEndpoint infoEndpoint() throws Exception { LinkedHashMap<String, Object> info = new LinkedHashMap<String, Object>(); for (String filename : getAllPropertiesFiles()) { Resource resource = new ClassPathResource("/" + filename); Properties properties = new Properties(); if (resource.exists()) { properties = PropertiesLoaderUtils.loadProperties(resource); String name = resource.getFilename(); info.put(name.replace(PROPERTIES_SUFFIX, PROPERTIES_SUFFIX_REPLACEMENT), Maps.fromProperties(properties)); } else {/*w ww . j ava 2 s . c o m*/ if (failWhenResourceNotExists()) { throw new RuntimeException("Resource : " + filename + " does not exist"); } else { log.info("Resource {} does not exist", filename); } } } return new InfoEndpoint(info); }
From source file:codes.writeonce.maven.plugins.soy.AbstractSoyMojo.java
protected SoyFileSet getSoyFileSet(List<Path> soyFiles) { final SoyFileSet.Builder soyFileSetBuilder = SoyFileSet.builder(); if (compileTimeGlobals != null) { soyFileSetBuilder.setCompileTimeGlobals(Maps.fromProperties(compileTimeGlobals)); }// ww w .j ava 2s . c om for (final Path soyFilePath : soyFiles) { soyFileSetBuilder.add(sources.toPath().resolve(soyFilePath).toFile()); } return soyFileSetBuilder.build(); }
From source file:org.apache.aurora.common.util.BuildInfo.java
private void fetchProperties() { LOG.info("Fetching build properties from " + resourcePath); InputStream in = ClassLoader.getSystemResourceAsStream(resourcePath); if (in == null) { LOG.warn("Failed to fetch build properties from " + resourcePath); return;//from w ww .j a va 2 s . co m } try { Properties buildProperties = new Properties(); buildProperties.load(in); properties = Maps.fromProperties(buildProperties); } catch (Exception e) { LOG.warn("Failed to load properties file " + resourcePath, e); } }