本文整理汇总了Java中com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto类的典型用法代码示例。如果您正苦于以下问题:Java EnumValueDescriptorProto类的具体用法?Java EnumValueDescriptorProto怎么用?Java EnumValueDescriptorProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumValueDescriptorProto类属于com.google.protobuf.DescriptorProtos包,在下文中一共展示了EnumValueDescriptorProto类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createEnum
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/**
* TODO (guptasu): Only needed to create NullValue enum. Check if this can be removed.
* Create the Protobuf.Enum instance from enumDescriptorProto.
*/
private static Enum createEnum(String enumName,
EnumDescriptorProto enumDescriptorProto, String fileName) {
com.google.protobuf.Enum.Builder coreEnumBuilder =
com.google.protobuf.Enum.newBuilder().setName(enumName);
coreEnumBuilder.setSyntax(Syntax.SYNTAX_PROTO3);
for (EnumValueDescriptorProto value : enumDescriptorProto.getValueList()) {
com.google.protobuf.EnumValue.Builder coreEnumValueBuilder =
com.google.protobuf.EnumValue.newBuilder();
coreEnumValueBuilder.setName(value.getName()).setNumber(value.getNumber());
coreEnumBuilder.addEnumvalue(coreEnumValueBuilder.build());
}
coreEnumBuilder.setSourceContext(SourceContext.newBuilder().setFileName(fileName));
return coreEnumBuilder.build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:23,代码来源:TypesBuilderFromDescriptor.java
示例2: EnumValueDescriptor
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private EnumValueDescriptor(
final FileDescriptor file,
final EnumDescriptor parent,
final Integer number) {
String name = "UNKNOWN_ENUM_VALUE_" + parent.getName() + "_" + number;
EnumValueDescriptorProto proto = EnumValueDescriptorProto
.newBuilder().setName(name).setNumber(number).build();
this.index = -1;
this.proto = proto;
this.file = file;
this.type = parent;
this.fullName = parent.getFullName() + '.' + proto.getName();
this.number = number;
// Don't add this descriptor into pool.
}
开发者ID:yeriomin,项目名称:play-store-api,代码行数:17,代码来源:Descriptors.java
示例3: testPackedEnumField
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
public void testPackedEnumField() throws Exception {
FileDescriptorProto fileDescriptorProto = FileDescriptorProto.newBuilder()
.setName("foo.proto")
.addEnumType(EnumDescriptorProto.newBuilder()
.setName("Enum")
.addValue(EnumValueDescriptorProto.newBuilder()
.setName("FOO")
.setNumber(1)
.build())
.build())
.addMessageType(DescriptorProto.newBuilder()
.setName("Message")
.addField(FieldDescriptorProto.newBuilder()
.setName("foo")
.setTypeName("Enum")
.setNumber(1)
.setLabel(FieldDescriptorProto.Label.LABEL_REPEATED)
.setOptions(DescriptorProtos.FieldOptions.newBuilder()
.setPacked(true)
.build())
.build())
.build())
.build();
Descriptors.FileDescriptor.buildFrom(
fileDescriptorProto, new FileDescriptor[0]);
}
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:27,代码来源:DescriptorsTest.java
示例4: generateEnum
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private EnumDescriptorProto generateEnum(Enum e) {
EnumDescriptorProto.Builder builder = EnumDescriptorProto.newBuilder();
builder.setName(getSimpleName(e.getName()));
for (EnumValue value : e.getEnumvalueList()) {
EnumValueDescriptorProto.Builder valueBuilder = EnumValueDescriptorProto.newBuilder();
valueBuilder.setName(value.getName());
valueBuilder.setNumber(value.getNumber());
valueBuilder.setOptions(generateEnumValueOptions(value));
builder.addValue(valueBuilder.build());
}
builder.setOptions(generateEnumOptions(e));
return builder.build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:14,代码来源:DescriptorGenerator.java
示例5: EnumType
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private EnumType(ProtoContainerElement parent, EnumDescriptorProto proto, String path) {
super(parent, proto.getName(), path);
this.proto = proto;
// Build values.
ImmutableList.Builder<EnumValue> valuesBuilder = ImmutableList.builder();
List<EnumValueDescriptorProto> valueProtos = proto.getValueList();
for (int i = 0; i < valueProtos.size(); i++) {
EnumValueDescriptorProto value = valueProtos.get(i);
String childPath = buildPath(path, EnumDescriptorProto.VALUE_FIELD_NUMBER, i);
valuesBuilder.add(EnumValue.create(this, value, childPath));
}
values = valuesBuilder.build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:15,代码来源:EnumType.java
示例6: decompile
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
protected void decompile(EnumDescriptorProto enumDescriptor) throws IOException {
indentedFormat("enum %s {", enumDescriptor.getName());
indent++;
if (enumDescriptor.hasOptions()) {
decompileOptions(enumDescriptor.getOptions());
}
for (EnumValueDescriptorProto value : enumDescriptor.getValueList()) {
indentedFormat("%s = %d%s;", value.getName(), value.getNumber(),
value.hasOptions() ? bracketedOptions(value.getOptions()) : "");
}
indent--;
indentedFormat("}");
}
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:14,代码来源:ProtobufDecompiler.java
示例7: EnumValueDescriptor
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private EnumValueDescriptor (final EnumValueDescriptorProto proto,
final FileDescriptor file,
final EnumDescriptor parent,
final int index)
throws DescriptorValidationException {
this.index = index;
this.proto = proto;
this.file = file;
type = parent;
fullName = parent.getFullName () + '.' + proto.getName ();
file.pool.addSymbol (this);
file.pool.addEnumValueByNumber (this);
}
开发者ID:BFergerson,项目名称:Beam,代码行数:16,代码来源:Descriptors.java
示例8: exitEnumField
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
@Override
public void exitEnumField(final EnumFieldContext ctx) {
final EnumValueDescriptorProto.Builder enumValueBuilder =
EnumValueDescriptorProto.Builder.class.cast(scopes.getProtoBuilder());
enumValueBuilder.setName(ctx.identifier().getText()).setNumber(
Integer.decode(ctx.enumValue().getText()));
scopes.popScope();
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:9,代码来源:ProtoFileParser.java
示例9: buildAllOptions
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private void buildAllOptions(final EnumDescriptorProto.Builder proto) {
if (!buildOptions(proto.getOptionsBuilder())) {
proto.clearOptions();
}
for (final EnumValueDescriptorProto.Builder enumValueProto : proto.getValueBuilderList()) {
if (!buildOptions(enumValueProto.getOptionsBuilder())) {
enumValueProto.clearOptions();
}
}
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:12,代码来源:OptionResolver.java
示例10: isCanonical
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private boolean isCanonical(final EnumDescriptorProto enumProto) {
if (enumProto.hasOptions() && enumProto.getOptions().getUninterpretedOptionCount() > 0) {
return false;
}
for (final EnumValueDescriptorProto enumValue : enumProto.getValueList()) {
if (enumValue.hasOptions() && enumValue.getOptions().getUninterpretedOptionCount() > 0) {
return false;
}
}
return true;
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:14,代码来源:FileDescriptorEx.java
示例11: setEnumFields
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
public void setEnumFields(List<EnumValueDescriptorProto> enumFields) {
this.enumFields = enumFields;
}
开发者ID:venus-boot,项目名称:saluki,代码行数:4,代码来源:PrintEnumFile.java
示例12: getOptions
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
public static List<Option> getOptions(EnumValueDescriptorProto descriptor) {
return getOptions(descriptor, true);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:DescriptorNormalization.java
示例13: create
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/**
* Creates an enum value backed up by the given proto.
*/
public static EnumValue create(EnumType parent, EnumValueDescriptorProto proto, String path) {
return new EnumValue(parent, proto, path);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:EnumValue.java
示例14: EnumValue
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
private EnumValue(EnumType parent, EnumValueDescriptorProto proto, String path) {
super(parent, proto.getName(), path);
this.proto = proto;
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:5,代码来源:EnumValue.java
示例15: getProto
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/**
* Returns the underlying proto representation.
*/
public EnumValueDescriptorProto getProto() {
return proto;
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:EnumValue.java
示例16: accept
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
@Accepts
protected void accept(EnumValueDescriptorProto.Builder val) {
pushParent(BuilderVisitorNodeInfo.create(val, currentFile));
visit(val.getOptionsBuilder());
popExpectedParent(val);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:BuilderVisitor.java
示例17: toProto
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/** Convert the descriptor to its protocol message representation. */
@Override
public EnumValueDescriptorProto toProto() {
return proto;
}
开发者ID:yeriomin,项目名称:play-store-api,代码行数:6,代码来源:Descriptors.java
示例18: setProto
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/** See {@link FileDescriptor#setProto}. */
private void setProto(final EnumValueDescriptorProto proto) {
this.proto = proto;
}
开发者ID:yeriomin,项目名称:play-store-api,代码行数:5,代码来源:Descriptors.java
示例19: addValue
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
public Builder addValue(String name, int num) {
EnumValueDescriptorProto.Builder enumValBuilder = EnumValueDescriptorProto.newBuilder();
enumValBuilder.setName(name).setNumber(num);
mEnumTypeBuilder.addValue(enumValBuilder.build());
return this;
}
开发者ID:os72,项目名称:protobuf-dynamic,代码行数:7,代码来源:EnumDefinition.java
示例20: testComplexNamespacePublicDependency
import com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto; //导入依赖的package包/类
/**
* Tests the translate/crosslink for an example with a more complex namespace
* referencing.
*/
public void testComplexNamespacePublicDependency() throws Exception {
FileDescriptorProto fooProto = FileDescriptorProto.newBuilder()
.setName("bar.proto")
.setPackage("a.b.c.d.bar.shared")
.addEnumType(EnumDescriptorProto.newBuilder()
.setName("MyEnum")
.addValue(EnumValueDescriptorProto.newBuilder()
.setName("BLAH")
.setNumber(1)))
.build();
FileDescriptorProto barProto = FileDescriptorProto.newBuilder()
.setName("foo.proto")
.addDependency("bar.proto")
.setPackage("a.b.c.d.foo.shared")
.addMessageType(DescriptorProto.newBuilder()
.setName("MyMessage")
.addField(FieldDescriptorProto.newBuilder()
.setLabel(FieldDescriptorProto.Label.LABEL_REPEATED)
.setTypeName("bar.shared.MyEnum")
.setName("MyField")
.setNumber(1)))
.build();
// translate and crosslink
FileDescriptor fooFile = Descriptors.FileDescriptor.buildFrom(
fooProto, new FileDescriptor[0]);
FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(
barProto, new FileDescriptor[]{fooFile});
// verify resulting descriptors
assertNotNull(barFile);
List<Descriptor> msglist = barFile.getMessageTypes();
assertNotNull(msglist);
assertTrue(msglist.size() == 1);
Descriptor desc = msglist.get(0);
if (desc.getName().equals("MyMessage")) {
assertNotNull(desc.getFields());
List<FieldDescriptor> fieldlist = desc.getFields();
assertNotNull(fieldlist);
assertTrue(fieldlist.size() == 1);
FieldDescriptor field = fieldlist.get(0);
assertTrue(field.getType() == FieldDescriptor.Type.ENUM);
assertTrue(field.getEnumType().getName().equals("MyEnum"));
assertTrue(field.getEnumType().getFile().getName().equals("bar.proto"));
assertTrue(field.getEnumType().getFile().getPackage().equals(
"a.b.c.d.bar.shared"));
}
}
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:51,代码来源:DescriptorsTest.java
注:本文中的com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论