public static Type getFieldType(Class<?> containingClass, String fieldName) {
    """
	Returns generic type for a field in a Thrift class. The type is the return
	type for the accessor method for the field (e.g. <code>isFieldName()</code>
	for a boolean type or <code>getFieldName</code> for other types). The return
	type works for both structs and unions. Reflecting directly based on
	fields does not work for unions.
	
	@return generic {@link Type} of the thrift field.
    """

    String suffix = // uppercase first letter
        fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);

    // look for getFieldName() or isFieldName()

    for(String prefix : new String[]{"get", "is"}) {
      try {
        Method method = containingClass.getDeclaredMethod(prefix + suffix);
        return method.getGenericReturnType();
      } catch (NoSuchMethodException e) {
      }
    }

    // look for bean style accessors get_fieldName and is_fieldName

    for(String prefix : new String[]{"get_", "is_"}) {
      try {
        Method method = containingClass.getDeclaredMethod(prefix + fieldName);
        return method.getGenericReturnType();
      } catch (NoSuchMethodException e) {
      }
    }

    throw new RuntimeException("could not find type for " + fieldName +
                                 " in " + containingClass);
  }
public static Type getFieldType(Class<?> containingClass, String fieldName) {

    String suffix = // uppercase first letter
        fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);

    // look for getFieldName() or isFieldName()

    for(String prefix : new String[]{"get", "is"}) {
      try {
        Method method = containingClass.getDeclaredMethod(prefix + suffix);
        return method.getGenericReturnType();
      } catch (NoSuchMethodException e) {
      }
    }

    // look for bean style accessors get_fieldName and is_fieldName

    for(String prefix : new String[]{"get_", "is_"}) {
      try {
        Method method = containingClass.getDeclaredMethod(prefix + fieldName);
        return method.getGenericReturnType();
      } catch (NoSuchMethodException e) {
      }
    }

    throw new RuntimeException("could not find type for " + fieldName +
                                 " in " + containingClass);
  }
public static Type getFieldType ( Class < ? > containingClass , String fieldName ) { String suffix = // uppercase first letter fieldName . substring ( 0 , 1 ) . toUpperCase ( ) + fieldName . substring ( 1 ) ; // look for getFieldName() or isFieldName() for ( String prefix : new String [ ] { "get" , "is" } ) { try { Method method = containingClass . getDeclaredMethod ( prefix + suffix ) ; return method . getGenericReturnType ( ) ; } catch ( NoSuchMethodException e ) { } } // look for bean style accessors get_fieldName and is_fieldName for ( String prefix : new String [ ] { "get_" , "is_" } ) { try { Method method = containingClass . getDeclaredMethod ( prefix + fieldName ) ; return method . getGenericReturnType ( ) ; } catch ( NoSuchMethodException e ) { } } throw new RuntimeException ( "could not find type for " + fieldName + " in " + containingClass ) ; }
Returns generic type for a field in a Thrift class. The type is the return
type for the accessor method for the field (e.g. <code>isFieldName()</code>
for a boolean type or <code>getFieldName</code> for other types). The return
type works for both structs and unions. Reflecting directly based on
fields does not work for unions.

@return generic {@link Type} of the thrift field.
Returns generic type for a field in a Thrift class . The type is the return type for the accessor method for the field ( e . g . <code > isFieldName () < / code > for a boolean type or <code > getFieldName< / code > for other types ) . The return type works for both structs and unions . Reflecting directly based on fields does not work for unions .