Class BaseFunctions


  • public class BaseFunctions
    extends Object
    • Constructor Detail

      • BaseFunctions

        public BaseFunctions()
    • Method Detail

      • isEqual

        public static boolean isEqual​(Object o1,
                                      Object o2)
        Checks two objects for equality
        Parameters:
        o1 - first object to check
        o2 - second object to check
        Returns:
        return true if given objects are equal otherwise false
      • isNumber

        public static boolean isNumber​(Object o)
        Checks if given object is a number
        Parameters:
        o - object to check
        Returns:
        return true if given object is a number otherwise false
      • previousVersion

        public static <T> T previousVersion​(List<T> versions)
        Retrieves previous version of given variable based on given versions
        Type Parameters:
        T - type of variable
        Parameters:
        versions - all available versions
        Returns:
        return previous version of the variable if exists otherwise null
      • variableVersion

        public static <T> T variableVersion​(List<T> versions,
                                            int version)
        Retrieves selected version of the variable from given versions
        Type Parameters:
        T - type of variable
        Parameters:
        versions - all available versions
        version - version number to retrieve
        Returns:
        version of the variable if exists under given version number otherwise null
      • log

        public static void log​(Object value)
      • log

        public static void log​(String template,
                               Object... items)
      • logWarning

        public static void logWarning​(String template,
                                      Object... items)
      • logError

        public static void logError​(String template,
                                    Object... items)
      • todayDate

        public static String todayDate()
      • todayYearAndMonth

        public static String todayYearAndMonth()
      • todayMonth

        public static String todayMonth()
      • previousMonth

        public static String previousMonth()
      • nextMonth

        public static String nextMonth()
      • todayDay

        public static String todayDay()
      • yesterdayDay

        public static String yesterdayDay()
      • tomorrowDay

        public static String tomorrowDay()
      • todayQuarter

        public static String todayQuarter()
      • previousQuarter

        public static String previousQuarter()
      • nextQuarter

        public static String nextQuarter()
      • identityName

        public static String identityName()
        Retrieves current user name if available otherwise null
        Returns:
        name of the user who is currently performing operation
      • identityName

        public static String identityName​(String whenNotFound)
        Retrieves current user name if available otherwise whenNotFound as fallback
        Parameters:
        whenNotFound - default name to be returned in case there is no user information available
        Returns:
        name of the user who is currently performing operation
      • identityProperty

        public static Object identityProperty​(String name)
        Retrieves property associated with user information e.g. email address etc
        Parameters:
        name - name of the property to fetch
        Returns:
        returns value of the property or null if not found
      • identityProperty

        public static Object identityProperty​(String name,
                                              String defaultValue)
        Retrieves property associated with user information e.g. email address etc in case of missing property it returns default value
        Parameters:
        name - name of the property to fetch
        default - value to be returned in case property is not found
        Returns:
        returns value of the property or default value given if not found
      • identityHasRole

        public static boolean identityHasRole​(String role)
        Verifies if user performing current operation has given role
        Parameters:
        role - name of the role user information should have
        Returns:
        true if user information has the role otherwise false (also when there is no user information available)
      • identityHasAnyRole

        public static boolean identityHasAnyRole​(String... roles)
        Verifies if user performing current operation has any of the given roles
        Parameters:
        roles - roles to be checked
        Returns:
        true if any of the given roles exists in user information
      • identityHasAllRoles

        public static boolean identityHasAllRoles​(String... roles)
        Verifies if user performing current operation has all of the given roles
        Parameters:
        roles - roles to be checked
        Returns:
        true if all of the given roles exists in user information