Package com.google.protobuf
Class Descriptors.FieldDescriptor
java.lang.Object
com.google.protobuf.Descriptors.GenericDescriptor
com.google.protobuf.Descriptors.FieldDescriptor
- All Implemented Interfaces:
com.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>,Comparable<Descriptors.FieldDescriptor>
- Enclosing class:
- Descriptors
public static final class Descriptors.FieldDescriptor
extends Descriptors.GenericDescriptor
implements Comparable<Descriptors.FieldDescriptor>, com.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
Describes a field of a message type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptionintCompare with anotherFieldDescriptor.Get the field's containing oneof.Get the field's containing type.Returns the field's default value.For enum fields, gets the field's type.For extensions defined nested within message types, gets the outer type.getFile()Get theFileDescriptorcontaining this descriptor.Get the field's fully-qualified name.intgetIndex()Get the index of this descriptor within its parent.Get the field's java type.For internal use only.For internal use only.For embedded message and group fields, gets the field's type.getName()Get the field's unqualified name.intGet the field's number.Get theFieldOptions, defined indescriptor.proto.getType()Get the field's declared type.booleanReturns true if the field had an explicitly-defined default value.internalMergeFrom(MessageLite.Builder to, MessageLite from) For internal use only.booleanIs this field an extension?booleanIs this field declared optional?booleanCan this field be packed? i.e.booleanisPacked()Does this field have the[packed = true]option?booleanIs this field declared repeated?booleanIs this field declared required?booleanFor internal use only.toProto()Convert the descriptor to its protocol message representation.
-
Method Details
-
getIndex
public int getIndex()Get the index of this descriptor within its parent.- See Also:
-
toProto
Convert the descriptor to its protocol message representation.- Specified by:
toProtoin classDescriptors.GenericDescriptor
-
getName
Get the field's unqualified name.- Specified by:
getNamein classDescriptors.GenericDescriptor
-
getNumber
public int getNumber()Get the field's number.- Specified by:
getNumberin interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
getFullName
Get the field's fully-qualified name.- Specified by:
getFullNamein classDescriptors.GenericDescriptor- See Also:
-
getJavaType
Get the field's java type. This is just for convenience. EveryFieldDescriptorProto.Typemaps to exactly one Java type. -
getLiteJavaType
For internal use only.- Specified by:
getLiteJavaTypein interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
getFile
Get theFileDescriptorcontaining this descriptor.- Specified by:
getFilein classDescriptors.GenericDescriptor
-
getType
Get the field's declared type. -
getLiteType
For internal use only.- Specified by:
getLiteTypein interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
needsUtf8Check
public boolean needsUtf8Check()For internal use only. -
isRequired
public boolean isRequired()Is this field declared required? -
isOptional
public boolean isOptional()Is this field declared optional? -
isRepeated
public boolean isRepeated()Is this field declared repeated?- Specified by:
isRepeatedin interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
isPacked
public boolean isPacked()Does this field have the[packed = true]option?- Specified by:
isPackedin interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
isPackable
public boolean isPackable()Can this field be packed? i.e. is it a repeated primitive field? -
hasDefaultValue
public boolean hasDefaultValue()Returns true if the field had an explicitly-defined default value. -
getDefaultValue
Returns the field's default value. Valid for all types except for messages and groups. For all other types, the object returned is of the same class that would returned by Message.getField(this). -
getOptions
Get theFieldOptions, defined indescriptor.proto. -
isExtension
public boolean isExtension()Is this field an extension? -
getContainingType
Get the field's containing type. For extensions, this is the type being extended, not the location where the extension was defined. SeegetExtensionScope(). -
getContainingOneof
Get the field's containing oneof. -
getExtensionScope
For extensions defined nested within message types, gets the outer type. Not valid for non-extension fields. For example, consider this.protofile:message Foo { extensions 1000 to max; } extend Foo { optional int32 baz = 1234; } message Bar { extend Foo { optional int32 qux = 4321; } }Bothbaz's andqux's containing type isFoo. However,baz's extension scope isnullwhilequx's extension scope isBar. -
getMessageType
For embedded message and group fields, gets the field's type. -
getEnumType
For enum fields, gets the field's type.- Specified by:
getEnumTypein interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-
compareTo
Compare with anotherFieldDescriptor. This orders fields in "canonical" order, which simply means ascending order by field number.othermust be a field of the same type -- i.e.getContainingType()must return the sameDescriptorfor both fields.- Specified by:
compareToin interfaceComparable<Descriptors.FieldDescriptor>- Returns:
- negative, zero, or positive if
thisis less than, equal to, or greater thanother, respectively.
-
internalMergeFrom
For internal use only. This is to satisfy the FieldDescriptorLite interface.- Specified by:
internalMergeFromin interfacecom.google.protobuf.FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
-