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

com.varmateo.yawg.spi.PageVars Maven / Gradle / Ivy

/**************************************************************************
 *
 * Copyright (c) 2016-2019 Yawg project contributors.
 *
 **************************************************************************/

package com.varmateo.yawg.spi;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;


/**
 * Set of variables made available to the template when generating the
 * final bake result.
 *
 * 

The meaning of this variables is template specific.

*/ public interface PageVars { /** * Retrieves the value of one of the variables. * * @param key The name of the variable whose value is to be * returned. * * @return An Optional containing the value of the * given variable, or nan empty Optional if the * variable does not exist. */ Optional get(String key); /** * Fetches a view of the set of page variables as an unmodifiable * map. * * @return An unmodifiable map containing all the vars. Each entry * corresponds to one page variable. */ Map asMap(); /** * Creates an empty PageVars. * * @return An empty PageVars. */ static PageVars empty() { return new PageVars() { @Override public Optional get(final String key) { return Optional.empty(); } @Override public Map asMap() { return Collections.emptyMap(); } }; } }