com.adobe.campaign.tests.bridge.service.MetaUtils Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2022 Adobe
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in
* accordance with the terms of the Adobe license agreement accompanying
* it.
*/
package com.adobe.campaign.tests.bridge.service;
import com.adobe.campaign.tests.bridge.service.exceptions.IBSTestException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class MetaUtils {
public static final List> ManagedClasses = Arrays.asList(String.class, int.class, long.class,
boolean.class, Integer.class, Long.class, Boolean.class, Date.class, Object.class);
public static final int RECURSION_DEPTH_LIMIT = Integer.parseInt(
ConfigValueHandlerIBS.DESERIALIZATION_DEPTH_LIMIT.fetchValue());
private static final Logger log = LogManager.getLogger();
/**
* Extracts a possible field name given a method name
*
* @param in_methodName The name of the method we want to extract
* @return A possible field name
*/
public static String extractFieldName(String in_methodName) {
//Remove "get"
String l_step1Transformation = in_methodName.startsWith("get") ? in_methodName.substring(3) : in_methodName;
if (l_step1Transformation.isEmpty()) {
return null;
}
//Transform first character to lower
return Character.toLowerCase(l_step1Transformation.charAt(0)) + l_step1Transformation.substring(1);
}
/**
* Used for deserializing Collections of unserializable objects.
*
* @param in_object A collection of complex objects
* @return A List of serialized Objects
*/
public static List extractValuesFromList(Collection in_object) {
return (List