本文整理汇总了Java中com.google.protobuf.DescriptorProtos.FileDescriptorSet.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptorSet.Builder方法的具体用法?Java FileDescriptorSet.Builder怎么用?Java FileDescriptorSet.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.FileDescriptorSet
的用法示例。
在下文中一共展示了FileDescriptorSet.Builder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolvesWithErrors
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
@Test
public void resolvesWithErrors() {
// Modify the descriptor injecting some errors.
FileDescriptorSet.Builder builder = descriptors.toBuilder();
builder
.getFileBuilder(0)
.getMessageTypeBuilder(0)
.getFieldBuilder(1) // required N n
.setTypeName("undef_N");
builder
.getFileBuilder(0)
.getMessageTypeBuilder(0)
.getFieldBuilder(2) // optional E e
.setTypeName("undef_E");
Model testApi = Model.create(builder.build());
testApi.registerProcessor(new Resolver());
Truth.assertThat(testApi.establishStage(Resolved.KEY)).isFalse();
Truth.assertThat(testApi.getDiagReporter().getDiagCollector().getErrorCount()).isEqualTo(2);
assertThat(testApi.getDiagReporter().getDiagCollector().getDiags().get(0).toString())
.contains("undef_N");
assertThat(testApi.getDiagReporter().getDiagCollector().getDiags().get(1).toString())
.contains("undef_E");
}
示例2: addDescriptorToFileSet
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private FileDescriptorSet.Builder addDescriptorToFileSet(FileDescriptorSet.Builder builder,
Descriptor descriptor, Set<FileDescriptorProto> fileProtoSet) {
List<? extends FileDescriptorProtoOrBuilder> fileList = builder.getFileOrBuilderList();
final FileDescriptor file = descriptor.getFile();
FileDescriptorProto proto = file.toProto();
if (fileList.contains(proto)) {
return builder;
}
builder.addFile(proto);
for (FileDescriptor dependency : file.getDependencies()) {
proto = dependency.toProto();
if (!fileList.contains(proto)) {
builder.addFile(proto);
}
}
return builder;
}
示例3: generate
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private FileDescriptorSet generate() {
FileDescriptorSet.Builder setBuilder = FileDescriptorSet.newBuilder();
for (Map.Entry<String, FileContents> entry : contentsByFile.entrySet()) {
FileContents contents = entry.getValue();
String fileName = entry.getKey();
if (!contents.apis.isEmpty() || !contents.types.isEmpty() || !contents.enums.isEmpty()) {
setBuilder.addFile(generateFile(fileName, contents));
}
}
return setBuilder.build();
}
示例4: resolvesOkWithPartialNames
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
@Test
public void resolvesOkWithPartialNames() {
// Modify the descriptor. Protoc generates full names, and
// we want to check whether we can also deal with partial names.
FileDescriptorSet.Builder builder = descriptors.toBuilder();
builder
.getFileBuilder(0)
.getMessageTypeBuilder(0)
.getFieldBuilder(1) // required N n
.setTypeName("N");
Model testApi = Model.create(builder.build());
testApi.registerProcessor(new Resolver());
Truth.assertThat(testApi.establishStage(Resolved.KEY)).isTrue();
Truth.assertThat(testApi.getDiagReporter().getDiagCollector().hasErrors()).isFalse();
}
示例5: build
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
/**
* Builds a dynamic schema
*
* @return the schema object
* @throws DescriptorValidationException
*/
public DynamicSchema build() throws DescriptorValidationException {
FileDescriptorSet.Builder fileDescSetBuilder = FileDescriptorSet.newBuilder();
fileDescSetBuilder.addFile(mFileDescProtoBuilder.build());
fileDescSetBuilder.mergeFrom(mFileDescSetBuilder.build());
return new DynamicSchema(fileDescSetBuilder.build());
}
示例6: testFileSetSerialization
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
@Test
public void testFileSetSerialization() throws Exception {
final FileDescriptorSet fileDescriptorSet = FileDescriptorSetBuilder.newBuilder()
.addDescriptor(TestAllTypes.getDescriptor()).build();
String fileDescriptorSetText = TextFormat.printToString(fileDescriptorSet);
FileDescriptorSet.Builder fileDescriptorSetBuilder = FileDescriptorSet.newBuilder();
TextFormat.merge(fileDescriptorSetText, fileDescriptorSetBuilder);
FileDescriptorSet actualFileSet = fileDescriptorSetBuilder.build();
assertThat(actualFileSet, equalTo(fileDescriptorSet));
}
示例7: accept
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
@Accepts
protected void accept(final FileDescriptorSet.Builder files) {
pushParent(BuilderVisitorNodeInfo.create(files));
visitRepeated(FileDescriptorSet.FILE_FIELD_NUMBER);
popExpectedParent(files);
}
示例8: create
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
public static BuilderVisitorNodeInfo create(FileDescriptorSet.Builder node) {
// FileDescriptorSet can't be contained within a FileDescriptor, so pass null here.
return new GenericNodeInfo(node, null);
}
示例9: validateAndGenerate
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
static FileDescriptorProto validateAndGenerate(HasStorage object,
ProtobufRowFormat.Type formatType,
FileDescriptorProto fileProto,
AISValidationOutput output) {
if (!(object instanceof Group)) {
output.reportFailure(new AISValidationFailure(new StorageDescriptionInvalidException(object, "is not a Group and cannot use Protocol Buffers")));
return null;
}
Group group = (Group)object;
if (formatType == ProtobufRowFormat.Type.SINGLE_TABLE) {
if (!group.getRoot().getChildJoins().isEmpty()) {
output.reportFailure(new AISValidationFailure(new StorageDescriptionInvalidException(object, "has more than one table")));
return null;
}
}
int currentVersion = sumTableVersions(group.getRoot());
if (fileProto != null) {
int storedVersion = fileProto.getOptions()
.getExtension(CustomOptions.GroupOptions.fdbsql).getVersion();
if (storedVersion == currentVersion) {
return fileProto;
}
}
FileDescriptorSet set = null;
if (fileProto != null) {
FileDescriptorSet.Builder builder = FileDescriptorSet.newBuilder();
builder.addFile(fileProto);
set = builder.build();
}
AISToProtobuf ais2p = new AISToProtobuf(formatType, set);
ais2p.addGroup(group);
set = ais2p.build();
fileProto = set.getFile(0); // Only added one group.
// Make sure it will build before committing to this format.
try {
FileDescriptor.buildFrom(fileProto, DEPENDENCIES);
}
catch (DescriptorValidationException ex) {
output.reportFailure(new AISValidationFailure(new ProtobufBuildException(ex)));
}
return fileProto;
}