Package com.google.protobuf
Class DescriptorMessageInfoFactory
- java.lang.Object
-
- com.google.protobuf.DescriptorMessageInfoFactory
-
- All Implemented Interfaces:
MessageInfoFactory
@ExperimentalApi final class DescriptorMessageInfoFactory extends java.lang.Object implements MessageInfoFactory
A factory for message info based on protobuf descriptors for aGeneratedMessageV3
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer
A helper class to determine whether a message type needs to implementisInitialized()
.private static class
DescriptorMessageInfoFactory.OneofState
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
GET_DEFAULT_INSTANCE_METHOD_NAME
private static DescriptorMessageInfoFactory
instance
private static DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer
isInitializedCheckAnalyzer
private static java.util.Set<java.lang.String>
specialFieldNames
-
Constructor Summary
Constructors Modifier Constructor Description private
DescriptorMessageInfoFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.reflect.Field
bitField(java.lang.Class<?> messageType, int index)
private static FieldInfo
buildOneofMember(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd, DescriptorMessageInfoFactory.OneofState oneofState, boolean enforceUtf8, Internal.EnumVerifier enumVerifier)
Builds info for a oneof member field.private static java.lang.reflect.Field
cachedSizeField(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
private static MessageInfo
convert(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
private static StructuralMessageInfo
convertProto2(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
private static StructuralMessageInfo
convertProto3(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
private static Descriptors.Descriptor
descriptorForType(java.lang.Class<?> messageType)
private static java.lang.reflect.Field
field(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
private static java.lang.reflect.Field
field(java.lang.Class<?> messageType, java.lang.String fieldName)
private static java.lang.String
getCachedSizeFieldName(Descriptors.FieldDescriptor fd)
private static Message
getDefaultInstance(java.lang.Class<?> messageType)
(package private) static java.lang.String
getFieldName(Descriptors.FieldDescriptor fd)
private static FieldType
getFieldType(Descriptors.FieldDescriptor fd)
static DescriptorMessageInfoFactory
getInstance()
private static java.lang.Class<?>
getOneofStoredType(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd, FieldType type)
private static java.lang.Class<?>
getOneofStoredTypeForMessage(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
Inspects the message to identify the stored type for a message field that is part of a oneof.private static java.lang.String
getterForField(java.lang.String snakeCase)
Constructs the name of the get method for the given field in the proto.private static java.lang.Class<?>
getTypeForRepeatedMessageField(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
Inspects the message to identify the message type of a repeated message field.boolean
isSupported(java.lang.Class<?> messageType)
Whether the message class is supported by this factory.MessageInfo
messageInfoFor(java.lang.Class<?> messageType)
Returns a information of the message class.private static boolean
needsIsInitializedCheck(Descriptors.Descriptor descriptor)
private static java.lang.String
snakeCaseToCamelCase(java.lang.String snakeCase)
This method must match exactly with the corresponding function in protocol compiler.
-
-
-
Field Detail
-
GET_DEFAULT_INSTANCE_METHOD_NAME
private static final java.lang.String GET_DEFAULT_INSTANCE_METHOD_NAME
- See Also:
- Constant Field Values
-
instance
private static final DescriptorMessageInfoFactory instance
-
specialFieldNames
private static final java.util.Set<java.lang.String> specialFieldNames
-
isInitializedCheckAnalyzer
private static DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer isInitializedCheckAnalyzer
-
-
Method Detail
-
getInstance
public static DescriptorMessageInfoFactory getInstance()
-
isSupported
public boolean isSupported(java.lang.Class<?> messageType)
Description copied from interface:MessageInfoFactory
Whether the message class is supported by this factory.- Specified by:
isSupported
in interfaceMessageInfoFactory
-
messageInfoFor
public MessageInfo messageInfoFor(java.lang.Class<?> messageType)
Description copied from interface:MessageInfoFactory
Returns a information of the message class.- Specified by:
messageInfoFor
in interfaceMessageInfoFactory
-
getDefaultInstance
private static Message getDefaultInstance(java.lang.Class<?> messageType)
-
descriptorForType
private static Descriptors.Descriptor descriptorForType(java.lang.Class<?> messageType)
-
convert
private static MessageInfo convert(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
-
needsIsInitializedCheck
private static boolean needsIsInitializedCheck(Descriptors.Descriptor descriptor)
-
convertProto2
private static StructuralMessageInfo convertProto2(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
-
convertProto3
private static StructuralMessageInfo convertProto3(java.lang.Class<?> messageType, Descriptors.Descriptor messageDescriptor)
-
buildOneofMember
private static FieldInfo buildOneofMember(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd, DescriptorMessageInfoFactory.OneofState oneofState, boolean enforceUtf8, Internal.EnumVerifier enumVerifier)
Builds info for a oneof member field.
-
getOneofStoredType
private static java.lang.Class<?> getOneofStoredType(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd, FieldType type)
-
getFieldType
private static FieldType getFieldType(Descriptors.FieldDescriptor fd)
-
bitField
private static java.lang.reflect.Field bitField(java.lang.Class<?> messageType, int index)
-
field
private static java.lang.reflect.Field field(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
-
cachedSizeField
private static java.lang.reflect.Field cachedSizeField(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
-
field
private static java.lang.reflect.Field field(java.lang.Class<?> messageType, java.lang.String fieldName)
-
getFieldName
static java.lang.String getFieldName(Descriptors.FieldDescriptor fd)
-
getCachedSizeFieldName
private static java.lang.String getCachedSizeFieldName(Descriptors.FieldDescriptor fd)
-
snakeCaseToCamelCase
private static java.lang.String snakeCaseToCamelCase(java.lang.String snakeCase)
This method must match exactly with the corresponding function in protocol compiler. See: https://github.com/google/protobuf/blob/v3.0.0/src/google/protobuf/compiler/java/java_helpers.cc#L153
-
getOneofStoredTypeForMessage
private static java.lang.Class<?> getOneofStoredTypeForMessage(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
Inspects the message to identify the stored type for a message field that is part of a oneof.
-
getTypeForRepeatedMessageField
private static java.lang.Class<?> getTypeForRepeatedMessageField(java.lang.Class<?> messageType, Descriptors.FieldDescriptor fd)
Inspects the message to identify the message type of a repeated message field.
-
getterForField
private static java.lang.String getterForField(java.lang.String snakeCase)
Constructs the name of the get method for the given field in the proto.
-
-