Class LocalOptimizationUtil


  • public final class LocalOptimizationUtil
    extends Object
    Utility methods leverages to perform locally optimized delegate calls.
    • Method Detail

      • isLocalServicePresent

        public static boolean isLocalServicePresent​(String serviceClassName)
        Checks to see if a local service is present for optimization. Requires that the class is in the classpath AND that service is registered and available via Spring. If only the class is available, but the Spring bean is not, will emit a warning.
        Parameters:
        serviceClassName - fully qualified class name of the service
        Returns:
        whether or not a local optimization is available
      • convertToBusinessObjectViaJson

        public static Object convertToBusinessObjectViaJson​(Collection<? extends TransferObject> transferObjectList,
                                                            com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts a List of TransferObjects to a List of corresponding BusinessObjects.
        Parameters:
        transferObjectList - list of transfer objects
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        list of business objects
      • convertToBusinessObjectViaJson

        public static Object convertToBusinessObjectViaJson​(FindByExampleCriteria<? extends TransferObject> criteria,
                                                            com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts FindByExampleCriteria with a TransferObject probe to a one containing the equivalent BusinessObject probe.
        Parameters:
        criteria - criteria containing a TransferObject probe
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        equivalent criteria containing a BusinessObject probe
      • convertToBusinessObjectViaJson

        public static Object convertToBusinessObjectViaJson​(TransferObject transferObject,
                                                            com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts a TransferObject to a corresponding BusinessObject.
        Parameters:
        transferObject - list of transfer objects
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        business object
      • convertResponseToTransferObjectViaJson

        public static Object convertResponseToTransferObjectViaJson​(Object input,
                                                                    Class<?> transferObjectTargetClass,
                                                                    com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).
        Parameters:
        input - the inbound ValueServiceResponse
        transferObjectTargetClass - the transfer object class we want to have in the result
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        a ValueServiceResponse with a TransferObject-based payload
      • convertResponseToTransferObjectListViaJson

        public static Object convertResponseToTransferObjectListViaJson​(Object input,
                                                                        Class<?> transferObjectTargetClass,
                                                                        com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).
        Parameters:
        input - the inbound ValueServiceResponse
        transferObjectTargetClass - the transfer object class we want to have in the result
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        a ValueServiceResponse with a TransferObject-based payload
      • convertResponseToTransferObjectPageWrapperViaJson

        public static Object convertResponseToTransferObjectPageWrapperViaJson​(Object input,
                                                                               Class<?> transferObjectTargetClass,
                                                                               com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).
        Parameters:
        input - the inbound ValueServiceResponse
        transferObjectTargetClass - the transfer object class we want to have in the result
        objectMapper - ObjectMapper to perform the transformation
        Returns:
        a ValueServiceResponse with a TransferObject-based payload
      • lookupBusinessObjectClassByTransferObject

        public static Class<?> lookupBusinessObjectClassByTransferObject​(Class<? extends TransferObject> transferObjectClass)
        Finds the BusinessObject class corresponding to a given TransferObject class.
        Parameters:
        transferObjectClass - the specific Transfer object class (e.g., foo.bar.SimpleDomain)
        Returns:
        the specific BusinessObject class (e.g., foo.bar.SimpleDomainBO)
      • lookupClassByName

        public static Class<?> lookupClassByName​(String className)
        Normal Class.forName(), but with implicit exception handling for cleaner overall code in this and related classes.
        Parameters:
        className - fully qualified class name to lookup
        Returns:
        the Class for that lookup value (or an UnrecoverableException, if not found)
      • getObjectMapper

        public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper​(String objectMapperManagerClassName)
        Looks up a ObjectMapperManager via reflection to avoid compile-time coupling between client and domain modules.
        Parameters:
        objectMapperManagerClassName - fully qualified class name of the ObjectMapperManager to lookup
        Returns:
        the resulting instance or an UnrecoverableException, if not found