test_class.file: BackEnd/Core/sailfish-core/src/test/java/com/exactpro/sf/aml/generator/TypeConverterTest.java
test_class.identifier: TypeConverterTest
test_class.superclass: extends AbstractTest
test_case.body: @Test
  	public void testFindConstByValue() throws Exception
  	{
          assertEquals("com.exactpro.sf.messages.testaml.components.SideITCH.BUY", TypeConverter.findConstantByValue(SideITCH.class, "66"));
          assertEquals("com.exactpro.sf.messages.testaml.components.SideITCH.SELL", TypeConverter.findConstantByValue(SideITCH.class, "83"));
  	}
test_case.class_method_signature: TypeConverterTest.testFindConstByValue()
test_case.full_signature: @Test public void testFindConstByValue()
test_case.identifier: testFindConstByValue
test_case.invocations: assertEquals findConstantByValue assertEquals findConstantByValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFindConstByValue()
focal_class.declarator: logger = LoggerFactory.getLogger(TypeConverter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(TypeConverter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: CAST_PATTERN = Pattern.compile("\\(\\s*\\w+(\\.\\w+\\s*)*\\)(?<value>.+)")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern CAST_PATTERN = Pattern.compile("\\(\\s*\\w+(\\.\\w+\\s*)*\\)(?<value>.+)");
focal_class.type: Pattern
focal_class.var_name: CAST_PATTERN
focal_class.file: BackEnd/Core/sailfish-core/src/main/java/com/exactpro/sf/aml/generator/TypeConverter.java
focal_class.identifier: TypeConverter
focal_class.class_method_signature: TypeConverter.TypeConverter()
focal_class.full_signature: private  TypeConverter()
focal_class.identifier: TypeConverter
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  TypeConverter()
focal_class.class_method_signature: TypeConverter.findConstant(Class<?> type, String constantName)
focal_class.full_signature: public static String findConstant(Class<?> type, String constantName)
focal_class.identifier: findConstant
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String constantName)
focal_class.return: String
focal_class.signature: String findConstant(Class<?> type, String constantName)
focal_class.class_method_signature: TypeConverter.findConstant(Class<?> type, String value, AtomicReference<Class<?>> constType)
focal_class.full_signature: public static String findConstant(Class<?> type, String value, AtomicReference<Class<?>> constType)
focal_class.identifier: findConstant
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String value, AtomicReference<Class<?>> constType)
focal_class.return: String
focal_class.signature: String findConstant(Class<?> type, String value, AtomicReference<Class<?>> constType)
focal_class.class_method_signature: TypeConverter.findConstantValue(Class<?> type, String name, Class<?> constType)
focal_class.full_signature: public static Object findConstantValue(Class<?> type, String name, Class<?> constType)
focal_class.identifier: findConstantValue
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String name, Class<?> constType)
focal_class.return: Object
focal_class.signature: Object findConstantValue(Class<?> type, String name, Class<?> constType)
focal_class.class_method_signature: TypeConverter.convert(Class<?> type, AtomicReference<String> value)
focal_class.full_signature: public static boolean convert(Class<?> type, AtomicReference<String> value)
focal_class.identifier: convert
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, AtomicReference<String> value)
focal_class.return: boolean
focal_class.signature: boolean convert(Class<?> type, AtomicReference<String> value)
focal_class.class_method_signature: TypeConverter.convert(Class<?> type, String value)
focal_class.full_signature: public static String convert(Class<?> type, String value)
focal_class.identifier: convert
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String value)
focal_class.return: String
focal_class.signature: String convert(Class<?> type, String value)
focal_class.class_method_signature: TypeConverter.findConstantByValue(Class<?> type, String value)
focal_class.full_signature: public static String findConstantByValue(Class<?> type, String value)
focal_class.identifier: findConstantByValue
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String value)
focal_class.return: String
focal_class.signature: String findConstantByValue(Class<?> type, String value)
focal_class.class_method_signature: TypeConverter.findConstByValue(Class<?> type, String value, Class<?> constType)
focal_class.full_signature: public static String findConstByValue(Class<?> type, String value, Class<?> constType)
focal_class.identifier: findConstByValue
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String value, Class<?> constType)
focal_class.return: String
focal_class.signature: String findConstByValue(Class<?> type, String value, Class<?> constType)
focal_class.class_method_signature: TypeConverter.convertToObject(Class<?> type, String value)
focal_class.full_signature: public static Object convertToObject(Class<?> type, String value)
focal_class.identifier: convertToObject
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, String value)
focal_class.return: Object
focal_class.signature: Object convertToObject(Class<?> type, String value)
focal_class.class_method_signature: TypeConverter.findConstructor(Class<?> type, Class<?> parameterType)
focal_class.full_signature: public static Constructor<?> findConstructor(Class<?> type, Class<?> parameterType)
focal_class.identifier: findConstructor
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type, Class<?> parameterType)
focal_class.return: Constructor<?>
focal_class.signature: Constructor<?> findConstructor(Class<?> type, Class<?> parameterType)
focal_class.class_method_signature: TypeConverter.inferConstructor(Class<?> type)
focal_class.full_signature: public static Constructor<?> inferConstructor(Class<?> type)
focal_class.identifier: inferConstructor
focal_class.modifiers: public static
focal_class.parameters: (Class<?> type)
focal_class.return: Constructor<?>
focal_class.signature: Constructor<?> inferConstructor(Class<?> type)
focal_method.body: public static String findConstByValue(Class<?> type, String value, Class<?> constType) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
  	{
  		if (type.isEnum())
  		{
  			Method[] methods = type.getDeclaredMethods();
  			for (Method method : methods)
  			{
                  if("getEnumValue".equals(method.getName())) {
  					if (method.getParameterTypes().length == 1)
  					{
                          Matcher matcher = CAST_PATTERN.matcher(value);
                          if(matcher.find()) {
                              value = matcher.group("value");
  						}
  						Object objArg = convertToObject(method.getParameterTypes()[0], value);
  						Object objVal = method.invoke(null, objArg);
                          return type.getCanonicalName() + "." + objVal;
  					}
  				}
  			}
  			for (Object constant : type.getEnumConstants())
  			{
  				if (constant.toString().equals(value))
  				{
                      return type.getCanonicalName() + "." + constant;
  				}
  			}
  			return null;
  		}
  
  		Field[] constants = type.getDeclaredFields();
  		for (Field constant : constants)
  		{
  			if ((constType == null || constant.getType().equals(constType))
  					&& ((constant.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC)
  					&& ((constant.getModifiers() & Modifier.STATIC) == Modifier.STATIC)
  					&& ((constant.getModifiers() & Modifier.FINAL) == Modifier.FINAL))
  			{
  				try {
  					Object objArg = convertToObject(constant.getType(), value);
  					Object cvalue = constant.get(null);
  					if (objArg.equals(cvalue)) {
  						return type.getCanonicalName()+"."+constant.getName();
  					}
  				} catch (Exception e) {
  					logger.warn("Value '{}' can not be converted to type {}", value, constant.getType());
  				}
  			}
  		}
  		return null;
  	}
focal_method.class_method_signature: TypeConverter.findConstByValue(Class<?> type, String value, Class<?> constType)
focal_method.full_signature: public static String findConstByValue(Class<?> type, String value, Class<?> constType)
focal_method.identifier: findConstByValue
focal_method.invocations: isEnum getDeclaredMethods equals getName getParameterTypes matcher find group convertToObject getParameterTypes invoke getCanonicalName getEnumConstants equals toString getCanonicalName getDeclaredFields equals getType getModifiers getModifiers getModifiers convertToObject getType get equals getCanonicalName getName warn getType
focal_method.modifiers: public static
focal_method.parameters: (Class<?> type, String value, Class<?> constType)
focal_method.return: String
focal_method.signature: String findConstByValue(Class<?> type, String value, Class<?> constType)