Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public LinkedHashMap<String, Boolean> addKeysValue(LinkedList<String> keys, Object value) throws IOException {
- int keyIndex = keys.size()-1;
- HashMap<String, Object> nestedMap = new HashMap<>();
- HashMap<String, Object> finalMap = new HashMap<>();
- nestedMap.put(keys.get(keyIndex), value);
- keyIndex--;
- boolean firstLoop = true;
- while (keyIndex > 0) {
- if (firstLoop) {
- firstLoop = false;
- finalMap = new HashMap<>();
- finalMap.put(keys.get(keyIndex), nestedMap);
- } else {
- HashMap<String, Object> tempMap = new HashMap<>();
- tempMap.put(keys.get(keyIndex), finalMap);
- finalMap = tempMap;
- }
- keyIndex--;
- }
- synchronized (HASHMAP_LOCK_OBJECT){
- DATA.put(keys.get(0), finalMap);
- }
- dumpOnModification(DATA);
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement