Package com.google.protobuf
Enum Class FieldType
- All Implemented Interfaces:
Serializable
,Comparable<FieldType>
,Constable
Enumeration identifying all relevant type information for a protobuf field.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FieldType.Collection
private final Class
<?> private static final Type[]
private final int
private final JavaType
private final boolean
private static final FieldType[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FieldType
(int id, FieldType.Collection collection, JavaType javaType) -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldType
forId
(int id) Looks up the appropriateFieldType
by it's identifier.private static Type
getGenericSuperList
(Class<?> clazz) Given a class, finds a generic super class or interface that extendsList
.Gets theJavaType
for this field.private static Type
getListParameter
(Class<?> clazz, Type[] realTypes) Inspects the inheritance hierarchy for the given class and finds the generic type parameter forList
.int
id()
A reliable unique identifier for this type.boolean
isList()
Indicates whether this field represents a list of values.boolean
isMap()
Indicates whether this field represents a map.boolean
isPacked()
Indicates whether a list field should be represented on the wire in packed form.boolean
Indicates whether this field type represents a primitive scalar value.boolean
isScalar()
Indicates whether this field type represents a scalar value.boolean
isValidForField
(Field field) private boolean
isValidForList
(Field field) static FieldType
Returns the enum constant of this class with the specified name.static FieldType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DOUBLE
-
FLOAT
-
INT64
-
UINT64
-
INT32
-
FIXED64
-
FIXED32
-
BOOL
-
STRING
-
MESSAGE
-
BYTES
-
UINT32
-
ENUM
-
SFIXED32
-
SFIXED64
-
SINT32
-
SINT64
-
GROUP
-
DOUBLE_LIST
-
FLOAT_LIST
-
INT64_LIST
-
UINT64_LIST
-
INT32_LIST
-
FIXED64_LIST
-
FIXED32_LIST
-
BOOL_LIST
-
STRING_LIST
-
MESSAGE_LIST
-
BYTES_LIST
-
UINT32_LIST
-
ENUM_LIST
-
SFIXED32_LIST
-
SFIXED64_LIST
-
SINT32_LIST
-
SINT64_LIST
-
DOUBLE_LIST_PACKED
-
FLOAT_LIST_PACKED
-
INT64_LIST_PACKED
-
UINT64_LIST_PACKED
-
INT32_LIST_PACKED
-
FIXED64_LIST_PACKED
-
FIXED32_LIST_PACKED
-
BOOL_LIST_PACKED
-
UINT32_LIST_PACKED
-
ENUM_LIST_PACKED
-
SFIXED32_LIST_PACKED
-
SFIXED64_LIST_PACKED
-
SINT32_LIST_PACKED
-
SINT64_LIST_PACKED
-
GROUP_LIST
-
MAP
-
-
Field Details
-
javaType
-
id
private final int id -
collection
-
elementType
-
primitiveScalar
private final boolean primitiveScalar -
VALUES
-
EMPTY_TYPES
-
-
Constructor Details
-
FieldType
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
id
public int id()A reliable unique identifier for this type. -
getJavaType
Gets theJavaType
for this field. For lists, this identifies the type of the elements contained within the list. -
isPacked
public boolean isPacked()Indicates whether a list field should be represented on the wire in packed form. -
isPrimitiveScalar
public boolean isPrimitiveScalar()Indicates whether this field type represents a primitive scalar value. If this istrue
, thenisScalar()
will also betrue
. -
isScalar
public boolean isScalar()Indicates whether this field type represents a scalar value. -
isList
public boolean isList()Indicates whether this field represents a list of values. -
isMap
public boolean isMap()Indicates whether this field represents a map. -
isValidForField
-
isValidForList
-
forId
Looks up the appropriateFieldType
by it's identifier.- Returns:
- the
FieldType
ornull
if not found.
-
getGenericSuperList
Given a class, finds a generic super class or interface that extendsList
.- Returns:
- the generic super class/interface, or
null
if not found.
-
getListParameter
Inspects the inheritance hierarchy for the given class and finds the generic type parameter forList
.- Parameters:
clazz
- the class to begin the search.realTypes
- the array of actual type parameters forclazz
. These will be used to substitute generic parameters up the inheritance hierarchy. Ifclazz
does not have any generic parameters, this list should be empty.- Returns:
- the
List
parameter.
-