Class SystemUtil
java.lang.Object
com.ssgllc.fish.service.util.registered.SystemUtil
-
Constructor Summary
ConstructorsConstructorDescriptionSystemUtil(org.springframework.core.env.Environment environment, com.ssgllc.fish.service.cache.EntityConfigCacheService entityConfigCacheService, com.ssgllc.fish.service.cache.CustomCacheService customCacheService, com.ssgllc.fish.config.ApplicationProperties applicationProperties, String springJpaDatabase, com.ssgllc.fish.service.cache.AbstractAppCacheRefreshMessageProducer appCacheRefreshMessageProducer) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidstatic <T> TevaluateExpression(Object rootObject, String expression, String returnTypeName, boolean mapContext) Evaluate given expression in context of a root object and return result in given type.
Example:
evaluateExpression(entity, "firstName == null", "java.lang.Boolean", false)
Returns:
Boolean true or false
static <T> TevaluateExpressionSafe(Object rootObject, String expression, String returnTypeName, boolean mapContext, T exceptionReturnValue) Safely evaluates a given expression within the context of a specified root object and returns the result cast to the specified type.
If the evaluation fails due to an exception, a fallback value is returned instead.static ObjectexecuteScript(String templateName, Map<String, Object> config, List<Map<String, Object>> payload, Object body) static StringgetAppConfig(String name) Retrieves the application configuration value associated with the given name.static booleangetAppConfigBoolean(String name, boolean defaultVal) Retrieves the application configuration value associated with the given name as a boolean, or returns the specified default value if the configuration is not found or cannot be parsed as a boolean.static IntegergetAppConfigInteger(String name, Integer defaultVal) Retrieves the application configuration value associated with the given name as an integer, or returns the specified default value if the configuration is not found or cannot be parsed as an integer.static StringgetAppConfigString(String name, String defaultVal) Retrieves the application configuration value associated with the given name, or returns the specified default value if the configuration is not found.static Stringstatic Stringstatic Objectstatic Stringstatic Stringstatic ObjectgetFromCache(String cacheName, String entryKey) static Stringstatic StringgetTextTemplate(String name) static voidstatic Objectstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic voidstatic void
-
Constructor Details
-
SystemUtil
public SystemUtil(org.springframework.core.env.Environment environment, com.ssgllc.fish.service.cache.EntityConfigCacheService entityConfigCacheService, com.ssgllc.fish.service.cache.CustomCacheService customCacheService, com.ssgllc.fish.config.ApplicationProperties applicationProperties, @Value("${spring.jpa.database}") String springJpaDatabase, com.ssgllc.fish.service.cache.AbstractAppCacheRefreshMessageProducer appCacheRefreshMessageProducer)
-
-
Method Details
-
getApplicationProperty
-
getBaseUrl
-
getSystemTimezone
-
getEcPrivateKeyFolder
-
getEnvironmentName
-
getAppConfig
Retrieves the application configuration value associated with the given name.- Parameters:
name- The name of the configuration key to retrieve.- Returns:
- The configuration value as a string, or null if no value is associated with the key.
Groovy example:
return systemUtil.getAppConfig("MyConfig")
Returns:
"MyConfigValue"
SpEL example:
#getAppConfig("MyConfig")
Returns:
"MyConfigValue"
-
getAppConfigString
Retrieves the application configuration value associated with the given name, or returns the specified default value if the configuration is not found.- Parameters:
name- The name of the configuration key to retrieve.defaultVal- The default value to return if no configuration is found for the key.- Returns:
- The configuration value as a string, or the specified default value if no value is associated with the key.
Groovy example:
return systemUtil.getAppConfigString("HeaderDisplayValue", "My Header")
Returns:
"My Header"
SpEL example:
#getAppConfigString("HeaderDisplayValue", "My Header")
Returns:
"My Header"
-
getAppConfigBoolean
Retrieves the application configuration value associated with the given name as a boolean, or returns the specified default value if the configuration is not found or cannot be parsed as a boolean.- Parameters:
name- The name of the configuration key to retrieve.defaultVal- The default value to return if no configuration is found for the key or if the value cannot be parsed as a boolean.- Returns:
- The configuration value as a boolean, or the specified default value.
Groovy example:
return systemUtil.getAppConfigBoolean("IsNewFeatureEnabled", false)
Returns:
false
SpEL example:
#getAppConfigBoolean("IsNewFeatureEnabled", false)
Returns:
false
-
getAppConfigInteger
Retrieves the application configuration value associated with the given name as an integer, or returns the specified default value if the configuration is not found or cannot be parsed as an integer.- Parameters:
name- The name of the configuration key to retrieve.defaultVal- The default value to return if no configuration is found for the key or if the value cannot be parsed as an integer.- Returns:
- The configuration value as an integer, or the specified default value.
Groovy example:
return systemUtil.getAppConfigInteger("MaxBatchSize", 100)
Returns:
100
SpEL example:
#getAppConfigInteger("MaxBatchSize", 100)
Returns:
100
-
getTextTemplate
-
getFromCache
-
getCache
-
executeScript
-
evaluateExpression
public static <T> T evaluateExpression(Object rootObject, String expression, String returnTypeName, boolean mapContext) throws ClassNotFoundException Evaluate given expression in context of a root object and return result in given type.
Example:
evaluateExpression(entity, "firstName == null", "java.lang.Boolean", false)
Returns:
Boolean true or false
- Parameters:
rootObject- object in scope where given expression will be evaluatedexpression- expression to be evaluatedreturnTypeName- fully qualified name of return type from expression evaluationmapContext- true if map accessor should be used in evaluation context, false otherwise- Returns:
- result from expression evaluation
- Throws:
ClassNotFoundException
-
evaluateExpressionSafe
public static <T> T evaluateExpressionSafe(Object rootObject, String expression, String returnTypeName, boolean mapContext, T exceptionReturnValue) throws ClassNotFoundException Safely evaluates a given expression within the context of a specified root object and returns the result cast to the specified type.
If the evaluation fails due to an exception, a fallback value is returned instead.- Parameters:
rootObject- The object serving as the evaluation context for the expression.expression- The expression to evaluate.returnTypeName- The fully qualified name of the expected return type.mapContext- Indicates whether the evaluation context should treat the rootObject as a map.exceptionReturnValue- The value to return if an exception occurs during evaluation.- Returns:
- The result of the evaluated expression, or
exceptionReturnValueif an error occurs.
Groovy example:
return systemUtil.evaluateExpressionSafe(entity, "firstName == null", "java.lang.Boolean", false, false)
Returns:
true
SpEL example:
#evaluateExpressionSafe(entity, "status == 'ACTIVE'", "java.lang.Boolean", false, false)
Returns:
true
- Throws:
ClassNotFoundException
-
trace
-
debug
-
info
-
warn
-
error
-
isTraceEnabled
public static boolean isTraceEnabled() -
isDebugEnabled
public static boolean isDebugEnabled() -
isInfoEnabled
public static boolean isInfoEnabled() -
isWarnEnabled
public static boolean isWarnEnabled() -
isErrorEnabled
public static boolean isErrorEnabled() -
inspect
-
isVectorSupported
public static boolean isVectorSupported()
-