/
parent_ini_config.java
45 lines (32 loc) · 1.12 KB
/
parent_ini_config.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package accessory;
import java.util.HashMap;
public abstract class parent_ini_config
{
protected boolean _populated = false;
protected abstract void populate_all_internal();
@SuppressWarnings("unchecked")
public static HashMap<String, Object> get_config_default_generic(String type_, HashMap<String, Object> vals_)
{
HashMap<String, Object> output = (HashMap<String, Object>)arrays.get_new(vals_);
for (String subtype: _types.get_subtypes(type_))
{
if (output.containsKey(subtype)) continue;
output.put(subtype, strings.DEFAULT);
}
return output;
}
protected void populate_all()
{
if (_populated) return;
populate_all_internal();
_populated = true;
}
protected boolean populate(String type_store_, String type_root_, HashMap<String, Object> vals_)
{
String type_store = config.check_type(type_store_);
if (!strings.is_ok(type_store) || !arrays.is_ok(vals_)) return false;
String type_root = config.check_type(type_root_);
if (!strings.is_ok(type_root)) type_root = type_store;
return arrays.value_exists(config.update_ini(type_store_, get_config_default_generic(type_root, vals_)), false);
}
}