Package com.google.protobuf
Class Descriptors.EnumDescriptor
- java.lang.Object
-
- com.google.protobuf.Descriptors.GenericDescriptor
-
- com.google.protobuf.Descriptors.EnumDescriptor
-
- All Implemented Interfaces:
Internal.EnumLiteMap<Descriptors.EnumValueDescriptor>
- Enclosing class:
- Descriptors
public static final class Descriptors.EnumDescriptor extends Descriptors.GenericDescriptor implements Internal.EnumLiteMap<Descriptors.EnumValueDescriptor>
Describes an enum type.
-
-
Field Summary
Fields Modifier and Type Field Description private Descriptors.DescriptorcontainingTypeprivate Descriptors.FileDescriptorfileprivate java.lang.StringfullNameprivate intindexprivate DescriptorProtos.EnumDescriptorProtoprotoprivate java.util.WeakHashMap<java.lang.Integer,java.lang.ref.WeakReference<Descriptors.EnumValueDescriptor>>unknownValuesprivate Descriptors.EnumValueDescriptor[]values
-
Constructor Summary
Constructors Modifier Constructor Description privateEnumDescriptor(DescriptorProtos.EnumDescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Descriptors.EnumValueDescriptorfindValueByName(java.lang.String name)Find an enum value by name.Descriptors.EnumValueDescriptorfindValueByNumber(int number)Find an enum value by number.Descriptors.EnumValueDescriptorfindValueByNumberCreatingIfUnknown(int number)Get the enum value for a number.Descriptors.DescriptorgetContainingType()If this is a nested type, get the outer descriptor, otherwise null.Descriptors.FileDescriptorgetFile()Get theDescriptors.FileDescriptorcontaining this descriptor.java.lang.StringgetFullName()Get the type's fully-qualified name.intgetIndex()Get the index of this descriptor within its parent.java.lang.StringgetName()Get the type's unqualified name.DescriptorProtos.EnumOptionsgetOptions()Get theEnumOptions, defined indescriptor.proto.(package private) intgetUnknownEnumValueDescriptorCount()java.util.List<Descriptors.EnumValueDescriptor>getValues()Get a list of defined values for this enum.private voidsetProto(DescriptorProtos.EnumDescriptorProto proto)DescriptorProtos.EnumDescriptorPrototoProto()Convert the descriptor to its protocol message representation.
-
-
-
Field Detail
-
index
private final int index
-
proto
private DescriptorProtos.EnumDescriptorProto proto
-
fullName
private final java.lang.String fullName
-
file
private final Descriptors.FileDescriptor file
-
containingType
private final Descriptors.Descriptor containingType
-
values
private Descriptors.EnumValueDescriptor[] values
-
unknownValues
private final java.util.WeakHashMap<java.lang.Integer,java.lang.ref.WeakReference<Descriptors.EnumValueDescriptor>> unknownValues
-
-
Constructor Detail
-
EnumDescriptor
private EnumDescriptor(DescriptorProtos.EnumDescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index) throws Descriptors.DescriptorValidationException
-
-
Method Detail
-
getIndex
public int getIndex()
Get the index of this descriptor within its parent.- See Also:
Descriptors.Descriptor.getIndex()
-
toProto
public DescriptorProtos.EnumDescriptorProto toProto()
Convert the descriptor to its protocol message representation.- Specified by:
toProtoin classDescriptors.GenericDescriptor
-
getName
public java.lang.String getName()
Get the type's unqualified name.- Specified by:
getNamein classDescriptors.GenericDescriptor
-
getFullName
public java.lang.String getFullName()
Get the type's fully-qualified name.- Specified by:
getFullNamein classDescriptors.GenericDescriptor- See Also:
Descriptors.Descriptor.getFullName()
-
getFile
public Descriptors.FileDescriptor getFile()
Get theDescriptors.FileDescriptorcontaining this descriptor.- Specified by:
getFilein classDescriptors.GenericDescriptor
-
getContainingType
public Descriptors.Descriptor getContainingType()
If this is a nested type, get the outer descriptor, otherwise null.
-
getOptions
public DescriptorProtos.EnumOptions getOptions()
Get theEnumOptions, defined indescriptor.proto.
-
getValues
public java.util.List<Descriptors.EnumValueDescriptor> getValues()
Get a list of defined values for this enum.
-
findValueByName
public Descriptors.EnumValueDescriptor findValueByName(java.lang.String name)
Find an enum value by name.- Parameters:
name- The unqualified name of the value (e.g. "FOO").- Returns:
- the value's descriptor, or
nullif not found.
-
findValueByNumber
public Descriptors.EnumValueDescriptor findValueByNumber(int number)
Find an enum value by number. If multiple enum values have the same number, this returns the first defined value with that number.- Specified by:
findValueByNumberin interfaceInternal.EnumLiteMap<Descriptors.EnumValueDescriptor>- Parameters:
number- The value's number.- Returns:
- the value's descriptor, or
nullif not found.
-
findValueByNumberCreatingIfUnknown
public Descriptors.EnumValueDescriptor findValueByNumberCreatingIfUnknown(int number)
Get the enum value for a number. If no enum value has this number, construct an EnumValueDescriptor for it.
-
getUnknownEnumValueDescriptorCount
int getUnknownEnumValueDescriptorCount()
-
setProto
private void setProto(DescriptorProtos.EnumDescriptorProto proto)
-
-