Class BaseFunctions
- java.lang.Object
-
- io.automatiko.engine.services.execution.BaseFunctions
-
public class BaseFunctions extends Object
-
-
Constructor Summary
Constructors Constructor Description BaseFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanidentityHasAllRoles(String... roles)Verifies if user performing current operation has all of the given rolesstatic booleanidentityHasAnyRole(String... roles)Verifies if user performing current operation has any of the given rolesstatic booleanidentityHasRole(String role)Verifies if user performing current operation has given rolestatic StringidentityName()Retrieves current user name if available otherwise nullstatic StringidentityName(String whenNotFound)Retrieves current user name if available otherwisewhenNotFoundas fallbackstatic ObjectidentityProperty(String name)Retrieves property associated with user information e.g. email address etcstatic ObjectidentityProperty(String name, String defaultValue)Retrieves property associated with user information e.g. email address etc in case of missing property it returns default valuestatic booleanisEqual(Object o1, Object o2)Checks two objects for equalitystatic booleanisNumber(Object o)Checks if given object is a numberstatic voidlog(Object value)static voidlog(String template, Object... items)static voidlogError(String template, Object... items)static voidlogWarning(String template, Object... items)static StringnextMonth()static StringnextQuarter()static StringpreviousMonth()static StringpreviousQuarter()static <T> TpreviousVersion(List<T> versions)Retrieves previous version of given variable based on given versionsstatic StringtodayDate()static StringtodayDay()static StringtodayMonth()static StringtodayQuarter()static StringtodayYearAndMonth()static StringtomorrowDay()static <T> TvariableVersion(List<T> versions, int version)Retrieves selected version of the variable from given versionsstatic StringyesterdayDay()
-
-
-
Method Detail
-
isEqual
public static boolean isEqual(Object o1, Object o2)
Checks two objects for equality- Parameters:
o1- first object to checko2- 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 versionsversion- version number to retrieve- Returns:
- version of the variable if exists under given version number otherwise null
-
log
public static void log(Object value)
-
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 otherwisewhenNotFoundas 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 fetchdefault- 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
-
-