Package com.typesafe.config

Examples of com.typesafe.config.ConfigValue


    Map<String, String> conf = new HashMap<String, String>();
    Config config = ConfigFactory.parseFileAnySyntax(new File(
        "conf/application.conf"));
    config = config.resolve();
    for (Entry<String, ConfigValue> entry : config.entrySet()) {
      ConfigValue value = entry.getValue();
      conf.put(entry.getKey(), value.unwrapped().toString());
    }
    conf.putAll(inMemoryDatabase());
    return conf;
  }
View Full Code Here


      init(null);
    }
    if (StringUtils.isBlank(key)) {
      return defaultValue;
    }
    ConfigValue raw = config.hasPath(key) ? config.getValue(key) : null;
    return (V) ((raw != null) ? raw.unwrapped() : defaultValue);
  }
View Full Code Here

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    String[] defRoles = {"USER", "MOD", "ADMIN"};
    Map<String, String> confMap = Config.getConfigMap();
    ConfigObject c = Config.getConfig().getObject("security.protected");
    ConfigValue apiSec = Config.getConfig().getValue("security.api");
    boolean enableRestFilter = apiSec != null && "enabled".equals(apiSec.unwrapped());

    for (String key : c.keySet()) {
      ConfigValue cv = c.get(key);
      ArrayList<String> patterns = new ArrayList<String>();
      ArrayList<String> roles = new ArrayList<String>();

      // if API security is disabled don't add any API related patterns
      // to the list of protected resources
View Full Code Here

    @Override
    public OptionValue next() {
      Entry<String, ConfigValue> e = entries.next();
      OptionValue v = new OptionValue();
      v.name = e.getKey();
      ConfigValue cv = e.getValue();
      v.type = OptionType.BOOT;
      switch(cv.valueType()){
      case BOOLEAN:
        v.kind = Kind.BOOLEAN;
        v.bool_val = (Boolean) cv.unwrapped();
        break;
      case LIST:
      case OBJECT:
      case STRING:
        v.string_val = cv.render();
        break;
      case NUMBER:
        v.kind = Kind.LONG;
        v.num_val = ((Number)cv.unwrapped()).longValue();
        break;
      }
      return v;
    }
View Full Code Here

    }

    @Override
    public boolean hasPath(String pathExpression) {
        Path path = Path.newPath(pathExpression);
        ConfigValue peeked;
        try {
            peeked = object.peekPath(path);
        } catch (ConfigException.NotResolved e) {
            throw ConfigImpl.improveNotResolved(path, e);
        }
        return peeked != null && peeked.valueType() != ConfigValueType.NULL;
    }
View Full Code Here

    private static void findPaths(Set<Map.Entry<String, ConfigValue>> entries, Path parent,
            AbstractConfigObject obj) {
        for (Map.Entry<String, ConfigValue> entry : obj.entrySet()) {
            String elem = entry.getKey();
            ConfigValue v = entry.getValue();
            Path path = Path.newKey(elem);
            if (parent != null)
                path = path.prepend(parent);
            if (v instanceof AbstractConfigObject) {
                findPaths(entries, path, (AbstractConfigObject) v);
View Full Code Here

        return find(path, null);
    }

    @Override
    public boolean getBoolean(String path) {
        ConfigValue v = find(path, ConfigValueType.BOOLEAN);
        return (Boolean) v.unwrapped();
    }
View Full Code Here

        ConfigValue v = find(path, ConfigValueType.BOOLEAN);
        return (Boolean) v.unwrapped();
    }

    private ConfigNumber getConfigNumber(String path) {
        ConfigValue v = find(path, ConfigValueType.NUMBER);
        return (ConfigNumber) v;
    }
View Full Code Here

        return getNumber(path).doubleValue();
    }

    @Override
    public String getString(String path) {
        ConfigValue v = find(path, ConfigValueType.STRING);
        return (String) v.unwrapped();
    }
View Full Code Here

        return getObject(path).toConfig();
    }

    @Override
    public Object getAnyRef(String path) {
        ConfigValue v = find(path, null);
        return v.unwrapped();
    }
View Full Code Here

TOP

Related Classes of com.typesafe.config.ConfigValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.