com.github.sviperll.maven.plugin.mustache.MapFiller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mustache-maven-plugin Show documentation
Show all versions of mustache-maven-plugin Show documentation
Render mustache templates during the build
/*
* Copyright 2015 Victor Nazarov .
*/
package com.github.sviperll.maven.plugin.mustache;
import java.util.Map;
import java.util.TreeMap;
/**
*
* @author Victor Nazarov <[email protected]>
*/
class MapFiller {
private final Map result;
MapFiller(Map result) {
this.result = result;
}
@SuppressWarnings("unchecked")
void put(String key, String value) {
int index = key.indexOf('.');
if (index < 0)
result.put(key, value);
else {
String prefix = key.substring(0, index);
Object mapObject = result.get(prefix);
Map map;
if (mapObject != null && mapObject instanceof Map)
map = (Map)mapObject;
else {
map = new TreeMap();
result.put(prefix, map);
}
MapFiller filler = new MapFiller(map);
filler.put(key.substring(index + 1), value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy