Java Code Examples for java.util.Properties.forEach()

The following are Jave code examples for showing how to use forEach() of the java.util.Properties class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jspare-vertx-ms-blueprint   File: JDBCProvider.java   Source Code and License Vote up 7 votes
public EntityManagerFactory build() {

		Properties properties = createProperties();

		DefaultPersistenceUnitInfoImpl persistenceUnitInfo = new DefaultPersistenceUnitInfoImpl(JSPARE_GATEWAY_DATASOURCE);
		persistenceUnitInfo.setProperties(properties);

		// Using RESOURCE_LOCAL for manage transactions on DAO side.
		persistenceUnitInfo.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL);

		// Add all entities to configuration
		ClassAnnotationMatchProcessor processor = (c) -> persistenceUnitInfo.addAnnotatedClassName(c);
		ClasspathScannerUtils.scanner(ALL_SCAN_QUOTE).matchClassesWithAnnotation(Entity.class, processor)
				.scan(NUMBER_CLASSPATH_SCANNER_THREADS);

		Map<String, Object> configuration = new HashMap<>();
		properties.forEach((k, v) -> configuration.put((String) k, v));

		EntityManagerFactory entityManagerFactory = persistenceProvider.createContainerEntityManagerFactory(persistenceUnitInfo,
				configuration);
		return entityManagerFactory;
	}
 
Example 2
Project: joanne   File: XMLManager.java   Source Code and License Vote up 5 votes
private Properties getFoldersList() throws FileNotFoundException, IOException{
    Properties p = new Properties();
            
        if(Files.exists(new File(PATH).toPath())){
            FileInputStream in = new FileInputStream(new File(PATH));
            p.loadFromXML(in);
            BiConsumer<Object,Object> bi = (x,y) ->{
                p.getProperty(x.toString(), new File(y.toString()).getName());
            };
            p.forEach(bi);

        }
        return p;
}
 
Example 3
Project: Cognizant-Intelligent-Test-Scripter   File: RemoteProxy.java   Source Code and License Vote up 5 votes
private static Properties decrypt(Properties prop) {
    Properties dprop = new Properties();
    dprop.putAll(prop);
    dprop.forEach((key, val) -> {
        if (val.toString().matches((".* Enc"))) {
            dprop.put(key, new String(Base64.decodeBase64(val.toString().replace(" Enc", ""))));
        }
    });
    return dprop;
}
 
Example 4
Project: openapi-annotation-processor   File: ParserCaseTester.java   Source Code and License Vote up 5 votes
private List<String> parseOptions() {
    if (!Files.exists(optionsPath)) {
        return Collections.emptyList();
    }
    Properties properties = new Properties();
    try (InputStream inputStream = Files.newInputStream(optionsPath)) {
        properties.load(inputStream);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    List<String> options = new ArrayList<>();
    properties.forEach((key, value) -> options.add("-A" + key + "=" + value));
    return options;
}
 
Example 5
Project: sponge   File: CommonsConfiguration.java   Source Code and License Vote up 4 votes
@Override
public void setVariables(Properties variables) {
    variables.forEach((name, value) -> config.setProperty((String) name, value));
}
 
Example 6
Project: openjdk-jdk10   File: ReleaseInfoPlugin.java   Source Code and License Vote up 4 votes
@Override
public void configure(Map<String, String> config) {
    String operation = config.get(NAME);
    if (operation == null) {
        return;
    }

    switch (operation) {
        case "add": {
            // leave it to open-ended! source, java_version, java_full_version
            // can be passed via this option like:
            //
            //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
            // and put whatever value that was passed in command line.

            config.keySet().stream()
                  .filter(s -> !NAME.equals(s))
                  .forEach(s -> release.put(s, config.get(s)));
        }
        break;

        case "del": {
            // --release-info del:keys=openjdk,java_version
            Utils.parseList(config.get(KEYS)).stream().forEach((k) -> {
                release.remove(k);
            });
        }
        break;

        default: {
            // --release-info <file>
            Properties props = new Properties();
            try (FileInputStream fis = new FileInputStream(operation)) {
                props.load(fis);
            } catch (IOException exp) {
                throw new UncheckedIOException(exp);
            }
            props.forEach((k, v) -> release.put(k.toString(), v.toString()));
        }
        break;
    }
}
 
Example 7
Project: smesh   File: SmeshProperties.java   Source Code and License Vote up 4 votes
public SmeshProperties(Properties nullableProperties) {
    if (nullableProperties != null) {
        nullableProperties.forEach((key, value) -> properties.put((String)key, (String) value));
    }
}
 
Example 8
Project: MeziLang   File: SystemEnvTest.java   Source Code and License Vote up 3 votes
public static void main(String[] args) {

    Map<String, String> env_map = System.getenv();

    out.println("Env Variables");
    env_map.forEach((key, val) -> out.println("[" + key + "] " + val));

    Properties ps = System.getProperties();

    out.println("\n\nProperties");
    ps.forEach((key, val) -> out.println("[" + key + "] " + val));

  }