Package com.google.protobuf
Class DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer
java.lang.Object
com.google.protobuf.DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer
- Enclosing class:
DescriptorMessageInfoFactory
A helper class to determine whether a message type needs to implement
isInitialized()
.
If a message type doesn't have any required fields or extensions (directly and transitively), it doesn't need to implement isInitialized() and can always return true there. It's a bit tricky to determine whether a type has transitive required fields because protobuf allows cycle references within the same .proto file (e.g., message Foo has a Bar field, and message Bar has a Foo field). For that we use Tarjan's strongly connected components algorithm to classify messages into strongly connected groups. Messages in the same group are transitively including each other, so they should either all have transitive required fields (or extensions), or none have.
This class is thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private final Map
<Descriptors.Descriptor, DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer.Node> private final Map
<Descriptors.Descriptor, Boolean> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
analyze
(DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer.StronglyConnectedComponent component) dfs
(Descriptors.Descriptor descriptor) boolean
needsIsInitializedCheck
(Descriptors.Descriptor descriptor)
-
Field Details
-
resultCache
-
index
private int index -
stack
-
nodeCache
private final Map<Descriptors.Descriptor,DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer.Node> nodeCache
-
-
Constructor Details
-
IsInitializedCheckAnalyzer
IsInitializedCheckAnalyzer()
-
-
Method Details
-
needsIsInitializedCheck
-
dfs
private DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer.Node dfs(Descriptors.Descriptor descriptor) -
analyze
private void analyze(DescriptorMessageInfoFactory.IsInitializedCheckAnalyzer.StronglyConnectedComponent component)
-