Package com.google.protobuf
Class DescriptorMessageInfoFactory
java.lang.Object
com.google.protobuf.DescriptorMessageInfoFactory
- All Implemented Interfaces:
MessageInfoFactory
@ExperimentalApi
final class DescriptorMessageInfoFactory
extends Object
implements MessageInfoFactory
A factory for message info based on protobuf descriptors for a
GeneratedMessageV3.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA helper class to determine whether a message type needs to implementisInitialized().private static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final DescriptorMessageInfoFactoryprivate static DescriptorMessageInfoFactory.IsInitializedCheckAnalyzerNames that should be avoided (in UpperCamelCase format). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Fieldprivate static FieldInfobuildOneofMember(Class<?> messageType, Descriptors.FieldDescriptor fd, DescriptorMessageInfoFactory.OneofState oneofState, boolean enforceUtf8, Internal.EnumVerifier enumVerifier) Builds info for a oneof member field.private static FieldcachedSizeField(Class<?> messageType, Descriptors.FieldDescriptor fd) private static MessageInfoconvert(Class<?> messageType, Descriptors.Descriptor messageDescriptor) private static ProtoSyntaxprivate static Descriptors.DescriptordescriptorForType(Class<?> messageType) private static Fieldfield(Class<?> messageType, Descriptors.FieldDescriptor fd) private static Fieldprivate static Stringprivate static MessagegetDefaultInstance(Class<?> messageType) (package private) static Stringprivate static FieldTypestatic DescriptorMessageInfoFactoryprivate static Class<?>getOneofStoredType(Class<?> messageType, Descriptors.FieldDescriptor fd, FieldType type) private static Class<?>getOneofStoredTypeForMessage(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 StringgetterForField(String snakeCase) Constructs the name of the get method for the given field in the proto.private static Class<?>getTypeForRepeatedMessageField(Class<?> messageType, Descriptors.FieldDescriptor fd) Inspects the message to identify the message type of a repeated message field.booleanisSupported(Class<?> messageType) Whether the message class is supported by this factory.messageInfoFor(Class<?> messageType) Returns a information of the message class.private static booleanneedsIsInitializedCheck(Descriptors.Descriptor descriptor) private static StringsnakeCaseToCamelCase(String snakeCase, boolean capFirst) Converts a snake case string into camel case.private static StringsnakeCaseToLowerCamelCase(String snakeCase) Converts a snake case string into lower camel case.private static StringsnakeCaseToUpperCamelCase(String snakeCase) Converts a snake case string into upper camel case.
-
Field Details
-
GET_DEFAULT_INSTANCE_METHOD_NAME
- See Also:
-
instance
-
specialFieldNames
Names that should be avoided (in UpperCamelCase format). Using them causes the compiler to generate accessors whose names collide with methods defined in base classes.Keep this list in sync with kForbiddenWordList in src/google/protobuf/compiler/java/java_helpers.cc
-
isInitializedCheckAnalyzer
-
-
Constructor Details
-
DescriptorMessageInfoFactory
private DescriptorMessageInfoFactory()
-
-
Method Details
-
getInstance
-
isSupported
Description copied from interface:MessageInfoFactoryWhether the message class is supported by this factory.- Specified by:
isSupportedin interfaceMessageInfoFactory
-
messageInfoFor
Description copied from interface:MessageInfoFactoryReturns a information of the message class.- Specified by:
messageInfoForin interfaceMessageInfoFactory
-
getDefaultInstance
-
descriptorForType
-
convertSyntax
-
convert
-
needsIsInitializedCheck
-
buildOneofMember
private static FieldInfo buildOneofMember(Class<?> messageType, Descriptors.FieldDescriptor fd, DescriptorMessageInfoFactory.OneofState oneofState, boolean enforceUtf8, Internal.EnumVerifier enumVerifier) Builds info for a oneof member field. -
getOneofStoredType
private static Class<?> getOneofStoredType(Class<?> messageType, Descriptors.FieldDescriptor fd, FieldType type) -
getFieldType
-
bitField
-
field
-
cachedSizeField
-
field
-
getFieldName
-
getCachedSizeFieldName
-
snakeCaseToLowerCamelCase
Converts a snake case string into lower camel case.Some examples:
snakeCaseToLowerCamelCase("foo_bar") => "fooBar" snakeCaseToLowerCamelCase("foo") => "foo"- Parameters:
snakeCase- the string in snake case to convert- Returns:
- the string converted to camel case, with a lowercase first character
-
snakeCaseToUpperCamelCase
Converts a snake case string into upper camel case.Some examples:
snakeCaseToUpperCamelCase("foo_bar") => "FooBar" snakeCaseToUpperCamelCase("foo") => "Foo"- Parameters:
snakeCase- the string in snake case to convert- Returns:
- the string converted to camel case, with an uppercase first character
-
snakeCaseToCamelCase
Converts a snake case string into camel case.For better readability, prefer calling either
snakeCaseToLowerCamelCase(String)orsnakeCaseToUpperCamelCase(String).Some examples:
snakeCaseToCamelCase("foo_bar", false) => "fooBar" snakeCaseToCamelCase("foo_bar", true) => "FooBar" snakeCaseToCamelCase("foo", false) => "foo" snakeCaseToCamelCase("foo", true) => "Foo" snakeCaseToCamelCase("Foo", false) => "foo" snakeCaseToCamelCase("fooBar", false) => "fooBar"This implementation of this method must exactly match the corresponding function in the protocol compiler. Specifically, the
UnderscoresToCamelCasefunction insrc/google/protobuf/compiler/java/java_helpers.cc.- Parameters:
snakeCase- the string in snake case to convertcapFirst- true if the first letter of the returned string should be uppercase. false if the first letter of the returned string should be lowercase.- Returns:
- the string converted to camel case, with an uppercase or lowercase first character
depending on if
capFirstis true or false, respectively
-
getOneofStoredTypeForMessage
private static Class<?> getOneofStoredTypeForMessage(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 Class<?> getTypeForRepeatedMessageField(Class<?> messageType, Descriptors.FieldDescriptor fd) Inspects the message to identify the message type of a repeated message field. -
getterForField
Constructs the name of the get method for the given field in the proto.
-