Class ReflectionUtils
java.lang.Object
com.broadleafcommerce.dataexchange.domain.util.ReflectionUtils
Utility for basic reflection operations.
- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindSuperClasses(ExchangeObject entity) Finds all superclasses but excludesObject.static voidflattenCorrelationHierarchy(ExchangeObject entity, Map<String, ExchangeObject> result) Recursively iterates over the properties of the entity and if they are instances ofExchangeObjectthis extracts them into aMapkeyed by theirExchangeObject.getCorrelationId().static Map<String,ExchangeObject> flattenCorrelationHierarchy(List<? extends ExchangeObject> entities) static voidflattenCorrelationHierarchy(List<? extends ExchangeObject> entities, Map<String, ExchangeObject> flattened) static voidresolveErrors(Function<Throwable, DataExchangeError> dataExchangeErrorSupplier, BatchContext<?> batchContext) This method walks the resulting object graph fromBatchContext.getSavedTopLevelEntities()that were either saved or errored, and assignserrorstoBatchContext.getResponseErrors().
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
findSuperClasses
Finds all superclasses but excludesObject. This does not return interfaces. Returns a list of superclasses, or null.- Parameters:
entity-- Returns:
-
flattenCorrelationHierarchy
public static void flattenCorrelationHierarchy(List<? extends ExchangeObject> entities, Map<String, ExchangeObject> flattened) -
flattenCorrelationHierarchy
public static Map<String,ExchangeObject> flattenCorrelationHierarchy(List<? extends ExchangeObject> entities) -
flattenCorrelationHierarchy
public static void flattenCorrelationHierarchy(@Nullable ExchangeObject entity, @NonNull Map<String, ExchangeObject> result) Recursively iterates over the properties of the entity and if they are instances ofExchangeObjectthis extracts them into aMapkeyed by theirExchangeObject.getCorrelationId(). This also sets their parent entity's correlationId.- Parameters:
entity-result-
-
resolveErrors
public static void resolveErrors(@NonNull Function<Throwable, DataExchangeError> dataExchangeErrorSupplier, @NonNull BatchContext<?> batchContext) This method walks the resulting object graph fromBatchContext.getSavedTopLevelEntities()that were either saved or errored, and assignserrorstoBatchContext.getResponseErrors(). The assignedDataExchangeError.setPath(String)will be a JSON Path, allowing callers to traverse the responses and determine which objects in the graph each respective error belongs with.- Parameters:
dataExchangeErrorSupplier- the function that supplies theDataExchangeErrorbased on the ThrowablebatchContext- theBatchContextthat contains the state of the batch, saved entities, and errors
-