public static final class Descriptors.FieldDescriptor extends Descriptors.GenericDescriptor implements java.lang.Comparable<Descriptors.FieldDescriptor>, FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
Modifier and Type | Class and Description |
---|---|
static class |
Descriptors.FieldDescriptor.JavaType |
static class |
Descriptors.FieldDescriptor.Type |
Modifier and Type | Field and Description |
---|---|
private Descriptors.OneofDescriptor |
containingOneof |
private Descriptors.Descriptor |
containingType |
private java.lang.Object |
defaultValue |
private Descriptors.EnumDescriptor |
enumType |
private Descriptors.Descriptor |
extensionScope |
private Descriptors.FileDescriptor |
file |
private java.lang.String |
fullName |
private int |
index |
private java.lang.String |
jsonName |
private Descriptors.Descriptor |
messageType |
private DescriptorProtos.FieldDescriptorProto |
proto |
private static WireFormat.FieldType[] |
table |
private Descriptors.FieldDescriptor.Type |
type |
Modifier | Constructor and Description |
---|---|
private |
FieldDescriptor(DescriptorProtos.FieldDescriptorProto proto,
Descriptors.FileDescriptor file,
Descriptors.Descriptor parent,
int index,
boolean isExtension) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Descriptors.FieldDescriptor other)
Compare with another
FieldDescriptor . |
private void |
crossLink()
Look up and cross-link all field types, etc.
|
private static java.lang.String |
fieldNameToJsonName(java.lang.String name) |
Descriptors.OneofDescriptor |
getContainingOneof()
Get the field's containing oneof.
|
Descriptors.Descriptor |
getContainingType()
Get the field's containing type.
|
java.lang.Object |
getDefaultValue()
Returns the field's default value.
|
Descriptors.EnumDescriptor |
getEnumType()
For enum fields, gets the field's type.
|
Descriptors.Descriptor |
getExtensionScope()
For extensions defined nested within message types, gets the outer
type.
|
Descriptors.FileDescriptor |
getFile()
Get the
FileDescriptor containing this descriptor. |
java.lang.String |
getFullName()
Get the field's fully-qualified name.
|
int |
getIndex()
Get the index of this descriptor within its parent.
|
Descriptors.FieldDescriptor.JavaType |
getJavaType()
Get the field's java type.
|
java.lang.String |
getJsonName()
Get the JSON name of this field.
|
WireFormat.JavaType |
getLiteJavaType()
For internal use only.
|
WireFormat.FieldType |
getLiteType()
For internal use only.
|
Descriptors.Descriptor |
getMessageType()
For embedded message and group fields, gets the field's type.
|
java.lang.String |
getName()
Get the field's unqualified name.
|
int |
getNumber()
Get the field's number.
|
DescriptorProtos.FieldOptions |
getOptions()
Get the
FieldOptions , defined in descriptor.proto . |
Descriptors.FieldDescriptor.Type |
getType()
Get the field's declared type.
|
boolean |
hasDefaultValue()
Returns true if the field had an explicitly-defined default value.
|
MessageLite.Builder |
internalMergeFrom(MessageLite.Builder to,
MessageLite from)
For internal use only.
|
boolean |
isExtension()
Is this field an extension?
|
boolean |
isMapField() |
boolean |
isOptional()
Is this field declared optional?
|
boolean |
isPackable()
Can this field be packed? i.e.
|
boolean |
isPacked()
Does this field have the
[packed = true] option or is this field
packable in proto3 and not explicitly setted to unpacked? |
boolean |
isRepeated()
Is this field declared repeated?
|
boolean |
isRequired()
Is this field declared required?
|
boolean |
needsUtf8Check()
For internal use only.
|
private void |
setProto(DescriptorProtos.FieldDescriptorProto proto)
|
DescriptorProtos.FieldDescriptorProto |
toProto()
Convert the descriptor to its protocol message representation.
|
java.lang.String |
toString() |
private static final WireFormat.FieldType[] table
private final int index
private DescriptorProtos.FieldDescriptorProto proto
private final java.lang.String fullName
private final java.lang.String jsonName
private final Descriptors.FileDescriptor file
private final Descriptors.Descriptor extensionScope
private Descriptors.FieldDescriptor.Type type
private Descriptors.Descriptor containingType
private Descriptors.Descriptor messageType
private Descriptors.OneofDescriptor containingOneof
private Descriptors.EnumDescriptor enumType
private java.lang.Object defaultValue
private FieldDescriptor(DescriptorProtos.FieldDescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index, boolean isExtension) throws Descriptors.DescriptorValidationException
public int getIndex()
Descriptors.Descriptor.getIndex()
public DescriptorProtos.FieldDescriptorProto toProto()
toProto
in class Descriptors.GenericDescriptor
public java.lang.String getName()
getName
in class Descriptors.GenericDescriptor
public int getNumber()
getNumber
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public java.lang.String getFullName()
getFullName
in class Descriptors.GenericDescriptor
Descriptors.Descriptor.getFullName()
public java.lang.String getJsonName()
public Descriptors.FieldDescriptor.JavaType getJavaType()
FieldDescriptorProto.Type
maps to exactly one Java type.public WireFormat.JavaType getLiteJavaType()
getLiteJavaType
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public Descriptors.FileDescriptor getFile()
FileDescriptor
containing this descriptor.getFile
in class Descriptors.GenericDescriptor
public Descriptors.FieldDescriptor.Type getType()
public WireFormat.FieldType getLiteType()
getLiteType
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public boolean needsUtf8Check()
public boolean isMapField()
public boolean isRequired()
public boolean isOptional()
public boolean isRepeated()
isRepeated
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public boolean isPacked()
[packed = true]
option or is this field
packable in proto3 and not explicitly setted to unpacked?isPacked
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public boolean isPackable()
public boolean hasDefaultValue()
public java.lang.Object getDefaultValue()
public DescriptorProtos.FieldOptions getOptions()
FieldOptions
, defined in descriptor.proto
.public boolean isExtension()
public Descriptors.Descriptor getContainingType()
getExtensionScope()
.public Descriptors.OneofDescriptor getContainingOneof()
public Descriptors.Descriptor getExtensionScope()
.proto
file:
message Foo { extensions 1000 to max; } extend Foo { optional int32 baz = 1234; } message Bar { extend Foo { optional int32 qux = 4321; } }Both
baz
's and qux
's containing type is Foo
.
However, baz
's extension scope is null
while
qux
's extension scope is Bar
.public Descriptors.Descriptor getMessageType()
public Descriptors.EnumDescriptor getEnumType()
getEnumType
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>
public int compareTo(Descriptors.FieldDescriptor other)
FieldDescriptor
. This orders fields in
"canonical" order, which simply means ascending order by field number.
other
must be a field of the same type -- i.e.
getContainingType()
must return the same Descriptor
for
both fields.compareTo
in interface java.lang.Comparable<Descriptors.FieldDescriptor>
this
is less than,
equal to, or greater than other
, respectively.public java.lang.String toString()
toString
in class java.lang.Object
private static java.lang.String fieldNameToJsonName(java.lang.String name)
private void crossLink() throws Descriptors.DescriptorValidationException
private void setProto(DescriptorProtos.FieldDescriptorProto proto)
public MessageLite.Builder internalMergeFrom(MessageLite.Builder to, MessageLite from)
internalMergeFrom
in interface FieldSet.FieldDescriptorLite<Descriptors.FieldDescriptor>