All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xdean.jex.util.lang.PropertiesBuilder Maven / Gradle / Ivy

The newest version!
package xdean.jex.util.lang;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesBuilder {

  public static PropertiesBuilder create() {
    return new PropertiesBuilder();
  }

  Map values = new HashMap<>();
  Properties defaults;

  private PropertiesBuilder() {
  }

  public PropertiesBuilder put(String key, String value) {
    values.put(key, value);
    return this;
  }

  public PropertiesBuilder defaults(Properties defaults) {
    this.defaults = defaults;
    return this;
  }

  public Properties build() {
    Properties p = defaults == null ? new Properties() : new Properties(defaults);
    values.forEach((k, v) -> p.setProperty(k, v));
    return p;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy