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:
<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"}
]
}
userLogin;someOutput
nial;Hello Nial!
Level userLogin
uses user.login
function as its level creator. Assuming this function is defined in Java:
public class LevelCreators {
@JavaPlugin("user.login")
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.