Class IfVar


public class IfVar extends MultipartVar
A basic if-else logic variable resolver.

The format for this var is one of the following:

  • "$IF{booleanArg,thenValue}"
  • "$IF{booleanArg,thenValue,elseValue}"

The boolean argument is any string.
The following values are interpreted as true: "true","TRUE","t", "T","1".
All else are interpreted as false

Example:

// Create a variable resolver that resolves system properties and $IF vars. VarResolver varResolver = VarResolver.create().vars(IfVar.class, SystemPropertiesVar.class).build(); // Use it! System.out.println(varResolver.resolve("Property $IF{$S{someBooleanFlag},IS,IS NOT} set!"));

Since this is a MultipartVar, any variables contained in the result will be recursively resolved.
Likewise, if the arguments contain any variables, those will be resolved before they are passed to this var.

See Also:
  • Field Details

  • Constructor Details

    • IfVar

      public IfVar()
      Constructor.
  • Method Details

    • resolve

      public String resolve(VarResolverSession session, String[] args)
      Description copied from class: MultipartVar
      The interface that needs to be implemented for this interface.
      Specified by:
      resolve in class MultipartVar
      Parameters:
      session - The session object used for a single instance of a string resolution.
      args - The arguments inside the variable.
      Returns:
      The resolved variable.