Level creator

Level creator is a special type of function, which is used to extract values from ParamContext. For a function to be used as a level creator, it has to follow level creator convention:

  • accept only one argument - subclass of ParamContext
  • return object of type compatible with level type that it will be used on
<level type> levelCreator(ParamContext context) {

Level creator does not have to be Java function. It can be written in any language supported by ParamEngine instance. It also does not have to be a simple find&return function. Level creator might apply some preprocessing or perform a database lookup. However be careful with fat level creators as complexity of these functions directly affects parameter evaluation time.


Lets define parameter with single input level that will be using level creator:

    name: "paramtereWithLevelCreator",
    inputLevels: 1,
    levels: [
        {name: "userLogin", type: "string", levelCreator: "user.login"},
        {name: "someOutput", type: "string"}
nial;Hello Nial!

Level userLogin uses user.login function as its level creator. Assuming this function is defined in Java:

public class LevelCreators {

    public String userLogin(DefaultContext context) {
        User user = context.get(User.class).login();

user.login level creator looks for User class object in context and returns user login.