Exemplo n.º 1
0
 public <E> E getGenericProperty(final String key, final E def) {
   if (def == null || Clazz.isPrimitive(def.getClass())) {
     return storage.get(key, def);
   } else {
     System.out.println("Read " + path + "." + key + (plain ? ".json" : ".ejs"));
     return JSonStorage.restoreFromFile(
         new File(path + "." + key + (plain ? ".json" : ".ejs")), def);
   }
 }
Exemplo n.º 2
0
  public Object getProperty(final String key, final Object def) {
    try {
      if (storage.hasProperty(key)) {
        return this.storage.get(key, (String) null);
      } else if (getObjectKey(key).exists()) {

        if (def != null) {
          return JSonStorage.restoreFromFile(getObjectKey(key), def);
        } else {
          TypeRef<?> ref = getType(key);
          System.out.println("Read " + path + "." + key + (plain ? ".json" : ".ejs"));
          if (ref == null) {
            Log.exception(new Exception(path + ".json." + key + " type missing"));
          }
          return JSonStorage.restoreFrom(getObjectKey(key), true, null, ref, null);
        }
      }
    } catch (Throwable e) {
      e.printStackTrace();
    }
    return def;
  }