public static final class Descriptors.EnumDescriptor extends Descriptors.GenericDescriptor implements Internal.EnumLiteMap<Descriptors.EnumValueDescriptor>
Modifier and Type | Method and Description |
---|---|
Descriptors.EnumValueDescriptor |
findValueByName(String name)
Find an enum value by name.
|
Descriptors.EnumValueDescriptor |
findValueByNumber(int number)
Find an enum value by number.
|
Descriptors.EnumValueDescriptor |
findValueByNumberCreatingIfUnknown(int number)
Get the enum value for a number.
|
Descriptors.Descriptor |
getContainingType()
If this is a nested type, get the outer descriptor, otherwise null.
|
Descriptors.FileDescriptor |
getFile()
Get the
Descriptors.FileDescriptor containing this descriptor. |
String |
getFullName()
Get the type's fully-qualified name.
|
int |
getIndex()
Get the index of this descriptor within its parent.
|
String |
getName()
Get the type's unqualified name.
|
DescriptorProtos.EnumOptions |
getOptions()
Get the
EnumOptions , defined in descriptor.proto . |
List<Descriptors.EnumValueDescriptor> |
getValues()
Get a list of defined values for this enum.
|
boolean |
isClosed()
Determines if the given enum is closed.
|
boolean |
isReservedName(String name)
Determines if the given field name is reserved.
|
boolean |
isReservedNumber(int number)
Determines if the given field number is reserved.
|
DescriptorProtos.EnumDescriptorProto |
toProto()
Convert the descriptor to its protocol message representation.
|
public int getIndex()
Descriptors.Descriptor.getIndex()
public DescriptorProtos.EnumDescriptorProto toProto()
toProto
in class Descriptors.GenericDescriptor
public String getName()
getName
in class Descriptors.GenericDescriptor
public String getFullName()
getFullName
in class Descriptors.GenericDescriptor
Descriptors.Descriptor.getFullName()
public Descriptors.FileDescriptor getFile()
Descriptors.FileDescriptor
containing this descriptor.getFile
in class Descriptors.GenericDescriptor
public boolean isClosed()
Closed enum means that it:
WARNING: Some runtimes currently have a quirk where non-closed enums are treated as closed when used as the type of fields defined in a `syntax = proto2;` file. This quirk is not present in all runtimes; as of writing, we know that:
Care should be taken when using this function to respect the target runtime's enum handling quirks.
public Descriptors.Descriptor getContainingType()
public DescriptorProtos.EnumOptions getOptions()
EnumOptions
, defined in descriptor.proto
.public List<Descriptors.EnumValueDescriptor> getValues()
public boolean isReservedNumber(int number)
public boolean isReservedName(String name)
public Descriptors.EnumValueDescriptor findValueByName(String name)
name
- the unqualified name of the value such as "FOO"null
if not foundpublic Descriptors.EnumValueDescriptor findValueByNumber(int number)
findValueByNumber
in interface Internal.EnumLiteMap<Descriptors.EnumValueDescriptor>
number
- The value's number.null
if not found.public Descriptors.EnumValueDescriptor findValueByNumberCreatingIfUnknown(int number)
Copyright © 2008–2025. All rights reserved.