public static String getMapFieldGenericParameterString ( FieldInfo field ) { FieldType fieldType = ProtobufProxyUtils . TYPE_MAPPING . get ( field . getGenericKeyType ( ) ) ; String keyClass ; String defaultKeyValue ; if ( fieldType == null ) { // may be object or enum if ( Enum . class . isAssignableFrom ( field . getGenericKeyType ( ) ) ) { keyClass = WIREFORMAT_CLSNAME + ".ENUM" ; Class < ? > declaringClass = field . getGenericKeyType ( ) ; Field [ ] fields = declaringClass . getFields ( ) ; if ( fields != null && fields . length > 0 ) { defaultKeyValue = ClassHelper . getInternalName ( field . getGenericKeyType ( ) . getCanonicalName ( ) ) + "." + fields [ 0 ] . getName ( ) ; } else { defaultKeyValue = "0" ; } } else { keyClass = WIREFORMAT_CLSNAME + ".MESSAGE" ; // check constructor boolean hasDefaultConstructor = ClassHelper . hasDefaultConstructor ( field . getGenericKeyType ( ) ) ; if ( ! hasDefaultConstructor ) { throw new IllegalArgumentException ( "Class '" + field . getGenericKeyType ( ) . getCanonicalName ( ) + "' must has default constructor method with no parameters." ) ; } defaultKeyValue = "new " + ClassHelper . getInternalName ( field . getGenericKeyType ( ) . getCanonicalName ( ) ) + "()" ; } } else { keyClass = WIREFORMAT_CLSNAME + "." + fieldType . toString ( ) ; defaultKeyValue = fieldType . getDefaultValue ( ) ; } fieldType = ProtobufProxyUtils . TYPE_MAPPING . get ( field . getGenericeValueType ( ) ) ; String valueClass ; String defaultValueValue ; if ( fieldType == null ) { // may be object or enum if ( Enum . class . isAssignableFrom ( field . getGenericeValueType ( ) ) ) { valueClass = WIREFORMAT_CLSNAME + ".ENUM" ; Class < ? > declaringClass = field . getGenericeValueType ( ) ; Field [ ] fields = declaringClass . getFields ( ) ; if ( fields != null && fields . length > 0 ) { defaultValueValue = ClassHelper . getInternalName ( field . getGenericeValueType ( ) . getCanonicalName ( ) ) + "." + fields [ 0 ] . getName ( ) ; } else { defaultValueValue = "0" ; } } else { valueClass = WIREFORMAT_CLSNAME + ".MESSAGE" ; // check constructor boolean hasDefaultConstructor = ClassHelper . hasDefaultConstructor ( field . getGenericeValueType ( ) ) ; if ( ! hasDefaultConstructor ) { throw new IllegalArgumentException ( "Class '" + field . getGenericeValueType ( ) . getCanonicalName ( ) + "' must has default constructor method with no parameters." ) ; } defaultValueValue = "new " + ClassHelper . getInternalName ( field . getGenericeValueType ( ) . getCanonicalName ( ) ) + "()" ; } } else { valueClass = WIREFORMAT_CLSNAME + "." + fieldType . toString ( ) ; defaultValueValue = fieldType . getDefaultValue ( ) ; } String joinedSentence = keyClass + "," + defaultKeyValue + "," + valueClass + "," + defaultValueValue ; return joinedSentence ; }
Gets the map field generic parameter string .