private void addFile(FileDescriptor file) { // Skip the file if it's already added. if (!files.add(file.getFullName())) { return; } for (FileDescriptor dependency : file.getDependencies()) { addFile(dependency); } for (Descriptor message : file.getMessageTypes()) { addMessage(message); } }
/** * Adds a message type and all types defined in the same .proto file as * well as all transitively imported .proto files to this {@link Builder}. */ public Builder add(Descriptor messageType) { if (types == null) { throw new IllegalStateException("A TypeRegistry.Builer can only be used once."); } addFile(messageType.getFile()); return this; }
/** * Adds message types and all types defined in the same .proto file as * well as all transitively imported .proto files to this {@link Builder}. */ public Builder add(Iterable<Descriptor> messageTypes) { if (types == null) { throw new IllegalStateException("A TypeRegistry.Builder can only be used once."); } for (Descriptor type : messageTypes) { addFile(type.getFile()); } return this; }