org.testng.mustache.Model Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testng Show documentation
Show all versions of testng Show documentation
Testing framework for Java
package org.testng.mustache;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Stack;
public class Model {
private Map m_model;
private Stack m_subModels = new Stack<>();
private static class SubModel {
String variable;
Object subModel;
}
public Model(Map model) {
m_model = model;
}
public void push(String variable, Object subModel) {
SubModel sl = new SubModel();
sl.variable = variable;
sl.subModel = subModel;
m_subModels.push(sl);
}
public Value resolveValue(String variable) {
if (! m_subModels.isEmpty()) {
for (SubModel object : m_subModels) {
Value value = resolveOnClass(object.subModel, variable);
if (value != null) {
return value;
}
}
}
return new Value(m_model.get(variable));
}
private Value resolveOnClass(Object object, String variable) {
// if (object instanceof Iterable) {
// Iterable it = (Iterable) object;
// List