All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jtwig.JtwigModel Maven / Gradle / Ivy

package org.jtwig;

import com.google.common.base.Optional;
import org.jtwig.reflection.model.Value;

import java.util.HashMap;
import java.util.Map;

public class JtwigModel {
    public static JtwigModel newModel(Map values) {
        JtwigModel model = newModel();
        for (Map.Entry entry : values.entrySet()) {
            model.with(entry.getKey(), entry.getValue());
        }
        return model;
    }
    public static JtwigModel newModel () {
        return new JtwigModel();
    }

    private final Map values;

    public JtwigModel() {
        this.values = new HashMap<>();
    }

    public JtwigModel with(String name, Object value) {
        values.put(name, new Value(value));
        return this;
    }

    public Optional get (String key) {
        return Optional.fromNullable(values.get(key));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy