本文整理汇总了Java中com.google.protobuf.DescriptorProtos.FileDescriptorSet.newBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptorSet.newBuilder方法的具体用法?Java FileDescriptorSet.newBuilder怎么用?Java FileDescriptorSet.newBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.FileDescriptorSet
的用法示例。
在下文中一共展示了FileDescriptorSet.newBuilder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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());
}
示例3: 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));
}
示例4: AISToProtobuf
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
public AISToProtobuf(ProtobufRowFormat.Type formatType, FileDescriptorSet priorSet) {
this.formatType = formatType;
this.priorSet = priorSet;
setBuilder = FileDescriptorSet.newBuilder();
}
示例5: 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;
}
示例6: Builder
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private Builder() {
mFileDescProtoBuilder = FileDescriptorProto.newBuilder();
mFileDescSetBuilder = FileDescriptorSet.newBuilder();
}