use of com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto in project aws-glue-schema-registry by awslabs.
the class FileDescriptorUtils method toEnum.
private static EnumElement toEnum(EnumDescriptorProto ed) {
String name = ed.getName();
ImmutableList.Builder<EnumConstantElement> constants = ImmutableList.builder();
for (EnumValueDescriptorProto ev : ed.getValueList()) {
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
constants.add(new EnumConstantElement(DEFAULT_LOCATION, ev.getName(), ev.getNumber(), "", options.build()));
}
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
if (ed.getOptions().hasAllowAlias()) {
OptionElement option = new OptionElement(ALLOW_ALIAS_OPTION, booleanKind, ed.getOptions().getAllowAlias(), false);
options.add(option);
}
return new EnumElement(DEFAULT_LOCATION, name, "", options.build(), constants.build());
}
use of com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto in project schema-registry by confluentinc.
the class ProtobufSchema method toEnum.
private static EnumElement toEnum(EnumDescriptorProto ed) {
String name = ed.getName();
log.trace("*** enum name: {}", name);
ImmutableList.Builder<EnumConstantElement> constants = ImmutableList.builder();
for (EnumValueDescriptorProto ev : ed.getValueList()) {
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
if (ev.getOptions().hasDeprecated()) {
OptionElement option = new OptionElement(DEPRECATED, Kind.BOOLEAN, ev.getOptions().getDeprecated(), false);
options.add(option);
}
if (ev.getOptions().hasExtension(MetaProto.enumValueMeta)) {
Meta meta = ev.getOptions().getExtension(MetaProto.enumValueMeta);
OptionElement option = toOption(CONFLUENT_ENUM_VALUE_META, meta);
if (option != null) {
options.add(option);
}
}
constants.add(new EnumConstantElement(DEFAULT_LOCATION, ev.getName(), ev.getNumber(), "", options.build()));
}
ImmutableList.Builder<ReservedElement> reserved = ImmutableList.builder();
for (EnumReservedRange range : ed.getReservedRangeList()) {
ReservedElement reservedElem = toReserved(range);
reserved.add(reservedElem);
}
for (String reservedName : ed.getReservedNameList()) {
ReservedElement reservedElem = new ReservedElement(DEFAULT_LOCATION, "", Collections.singletonList(reservedName));
reserved.add(reservedElem);
}
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
if (ed.getOptions().hasAllowAlias()) {
OptionElement option = new OptionElement(ALLOW_ALIAS, Kind.BOOLEAN, ed.getOptions().getAllowAlias(), false);
options.add(option);
}
if (ed.getOptions().hasDeprecated()) {
OptionElement option = new OptionElement(DEPRECATED, Kind.BOOLEAN, ed.getOptions().getDeprecated(), false);
options.add(option);
}
if (ed.getOptions().hasExtension(MetaProto.enumMeta)) {
Meta meta = ed.getOptions().getExtension(MetaProto.enumMeta);
OptionElement option = toOption(CONFLUENT_ENUM_META, meta);
if (option != null) {
options.add(option);
}
}
return new EnumElement(DEFAULT_LOCATION, name, "", options.build(), constants.build(), reserved.build());
}
use of com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto in project apicurio-registry by Apicurio.
the class FileDescriptorUtils method toEnum.
private static EnumElement toEnum(EnumDescriptorProto ed) {
String name = ed.getName();
ImmutableList.Builder<EnumConstantElement> constants = ImmutableList.builder();
for (EnumValueDescriptorProto ev : ed.getValueList()) {
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
constants.add(new EnumConstantElement(DEFAULT_LOCATION, ev.getName(), ev.getNumber(), "", options.build()));
}
ImmutableList.Builder<OptionElement> options = ImmutableList.builder();
if (ed.getOptions().hasAllowAlias()) {
OptionElement option = new OptionElement(ALLOW_ALIAS_OPTION, booleanKind, ed.getOptions().getAllowAlias(), false);
options.add(option);
}
return new EnumElement(DEFAULT_LOCATION, name, "", options.build(), constants.build());
}
Aggregations