org.seedstack.maven.components.templating.YamlClassConfig Maven / Gradle / Ivy
The newest version!
/*
* Copyright © 2013-2021, The SeedStack authors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.maven.components.templating;
import com.mitchellbosecke.pebble.extension.Function;
import java.util.List;
import java.util.Map;
public class YamlClassConfig implements Function {
private final String packageName;
YamlClassConfig(String packageName) {
this.packageName = packageName;
}
@Override
public Object execute(Map args) {
StringBuilder sb = new StringBuilder("classes:\n");
String indent = " ";
for (String part : packageName.split("\\.")) {
sb.append(indent).append(part).append(":\n");
indent = indent + " ";
}
int index = 0;
String key = "";
for (Object arg : args.values()) {
if (index % 2 == 0) {
key = String.valueOf(arg);
} else {
sb.append(indent).append(key).append(": ").append(arg).append("\n");
}
index++;
}
return sb.toString();
}
@Override
public List getArgumentNames() {
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy