Class ConditionFunctions

java.lang.Object
org.apache.maven.internal.impl.model.profile.ConditionFunctions

public class ConditionFunctions extends Object
Provides a set of functions for evaluating profile activation conditions. These functions can be used in profile activation expressions to determine whether a profile should be activated based on various criteria.
  • Constructor Details

    • ConditionFunctions

      public ConditionFunctions(ProfileActivationContext context, VersionParser versionParser)
      Constructs a new ConditionFunctions instance.
      Parameters:
      context - The profile activation context
      versionParser - The version parser for comparing versions
  • Method Details

    • length

      public Object length(List<Object> args)
      Returns the length of the given string.
      Parameters:
      args - A list containing a single string argument
      Returns:
      The length of the string
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
    • upper

      public Object upper(List<Object> args)
      Converts the given string to uppercase.
      Parameters:
      args - A list containing a single string argument
      Returns:
      The uppercase version of the input string
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
    • lower

      public Object lower(List<Object> args)
      Converts the given string to lowercase.
      Parameters:
      args - A list containing a single string argument
      Returns:
      The lowercase version of the input string
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
    • substring

      public Object substring(List<Object> args)
      Returns a substring of the given string.
      Parameters:
      args - A list containing 2 or 3 arguments: the string, start index, and optionally end index
      Returns:
      The substring
      Throws:
      IllegalArgumentException - if the number of arguments is not 2 or 3
    • indexOf

      public Object indexOf(List<Object> args)
      Finds the index of a substring within a string.
      Parameters:
      args - A list containing two strings: the main string and the substring to find
      Returns:
      The index of the substring, or -1 if not found
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly two
    • contains

      public Object contains(List<Object> args)
      Checks if a string contains a given substring.
      Parameters:
      args - A list containing two strings: the main string and the substring to check
      Returns:
      true if the main string contains the substring, false otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly two
    • matches

      public Object matches(List<Object> args)
      Checks if a string matches a given regular expression.
      Parameters:
      args - A list containing two strings: the string to check and the regex pattern
      Returns:
      true if the string matches the regex, false otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly two
    • not

      public Object not(List<Object> args)
      Negates a boolean value.
      Parameters:
      args - A list containing a single boolean argument
      Returns:
      The negation of the input boolean
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
    • if_

      public Object if_(List<Object> args)
      Implements an if-then-else operation.
      Parameters:
      args - A list containing three arguments: condition, value if true, value if false
      Returns:
      The second argument if the condition is true, the third argument otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly three
    • exists

      public Object exists(List<Object> args)
      Checks if a file or directory exists at the given path.
      Parameters:
      args - A list containing a single string argument representing the path
      Returns:
      true if the file or directory exists, false otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
      ModelBuilderException - if a problem occurs while walking the file system
      InterpolatorException - if an error occurs during interpolation
    • missing

      public Object missing(List<Object> args)
      Checks if a file or directory is missing at the given path.
      Parameters:
      args - A list containing a single string argument representing the path
      Returns:
      true if the file or directory does not exist, false otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly one
      ModelBuilderException - if a problem occurs while walking the file system
      InterpolatorException - if an error occurs during interpolation
    • inrange

      public Object inrange(List<Object> args)
      Checks if a version is within a specified version range.
      Parameters:
      args - A list containing two strings: the version to check and the version range
      Returns:
      true if the version is within the range, false otherwise
      Throws:
      IllegalArgumentException - if the number of arguments is not exactly two