add TCN#setIfAbsent
All checks were successful
/ Build & Publish (push) Successful in 48s

This commit is contained in:
Daniella 2024-06-25 07:10:03 +02:00
parent 015f314db0
commit aec5c07984
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -63,6 +63,22 @@ public class TCN {
map.set(key, o);
}
/**
* Sets something in the map if it doesn't exist
* @param key Key
* @param o Object, can be a native type, string, or another TCN (or TCNArray)
*/
public void setIfAbsent(String key, Object o) {
/*TLMap<String, Object> map = this.map;
ArrayList<String> path = new ArrayList<>(Arrays.asList(key.split("#")));
while (path.size() > 1) {
map = ((TCN) map.get(path.remove(0))).map;
}
*/
map.setIfNull(key, o);
}
public String getString(String key) {
Object o = map.get(key);
if(o != null)