Package com.google.protobuf
Enum FieldType
- java.lang.Object
-
- java.lang.Enum<FieldType>
-
- com.google.protobuf.FieldType
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<FieldType>
@ExperimentalApi public enum FieldType extends java.lang.Enum<FieldType>
Enumeration identifying all relevant type information for a protobuf field.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classFieldType.Collection
-
Enum Constant Summary
-
Field Summary
Fields Modifier and Type Field Description private FieldType.Collectioncollectionprivate java.lang.Class<?>elementTypeprivate static java.lang.reflect.Type[]EMPTY_TYPESprivate intidprivate JavaTypejavaTypeprivate booleanprimitiveScalarprivate static FieldType[]VALUES
-
Constructor Summary
Constructors Modifier Constructor Description privateFieldType(int id, FieldType.Collection collection, JavaType javaType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FieldTypeforId(int id)Looks up the appropriateFieldTypeby it's identifier.private static java.lang.reflect.TypegetGenericSuperList(java.lang.Class<?> clazz)Given a class, finds a generic super class or interface that extendsList.JavaTypegetJavaType()Gets theJavaTypefor this field.private static java.lang.reflect.TypegetListParameter(java.lang.Class<?> clazz, java.lang.reflect.Type[] realTypes)Inspects the inheritance hierarchy for the given class and finds the generic type parameter forList.intid()A reliable unique identifier for this type.booleanisList()Indicates whether this field represents a list of values.booleanisMap()Indicates whether this field represents a map.booleanisPacked()Indicates whether a list field should be represented on the wire in packed form.booleanisPrimitiveScalar()Indicates whether this field type represents a primitive scalar value.booleanisScalar()Indicates whether this field type represents a scalar value.booleanisValidForField(java.lang.reflect.Field field)Indicates whether or not thisFieldTypecan be applied to the givenField.private booleanisValidForList(java.lang.reflect.Field field)static FieldTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static FieldType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
DOUBLE
public static final FieldType DOUBLE
-
FLOAT
public static final FieldType FLOAT
-
INT64
public static final FieldType INT64
-
UINT64
public static final FieldType UINT64
-
INT32
public static final FieldType INT32
-
FIXED64
public static final FieldType FIXED64
-
FIXED32
public static final FieldType FIXED32
-
BOOL
public static final FieldType BOOL
-
STRING
public static final FieldType STRING
-
MESSAGE
public static final FieldType MESSAGE
-
BYTES
public static final FieldType BYTES
-
UINT32
public static final FieldType UINT32
-
ENUM
public static final FieldType ENUM
-
SFIXED32
public static final FieldType SFIXED32
-
SFIXED64
public static final FieldType SFIXED64
-
SINT32
public static final FieldType SINT32
-
SINT64
public static final FieldType SINT64
-
GROUP
public static final FieldType GROUP
-
DOUBLE_LIST
public static final FieldType DOUBLE_LIST
-
FLOAT_LIST
public static final FieldType FLOAT_LIST
-
INT64_LIST
public static final FieldType INT64_LIST
-
UINT64_LIST
public static final FieldType UINT64_LIST
-
INT32_LIST
public static final FieldType INT32_LIST
-
FIXED64_LIST
public static final FieldType FIXED64_LIST
-
FIXED32_LIST
public static final FieldType FIXED32_LIST
-
BOOL_LIST
public static final FieldType BOOL_LIST
-
STRING_LIST
public static final FieldType STRING_LIST
-
MESSAGE_LIST
public static final FieldType MESSAGE_LIST
-
BYTES_LIST
public static final FieldType BYTES_LIST
-
UINT32_LIST
public static final FieldType UINT32_LIST
-
ENUM_LIST
public static final FieldType ENUM_LIST
-
SFIXED32_LIST
public static final FieldType SFIXED32_LIST
-
SFIXED64_LIST
public static final FieldType SFIXED64_LIST
-
SINT32_LIST
public static final FieldType SINT32_LIST
-
SINT64_LIST
public static final FieldType SINT64_LIST
-
DOUBLE_LIST_PACKED
public static final FieldType DOUBLE_LIST_PACKED
-
FLOAT_LIST_PACKED
public static final FieldType FLOAT_LIST_PACKED
-
INT64_LIST_PACKED
public static final FieldType INT64_LIST_PACKED
-
UINT64_LIST_PACKED
public static final FieldType UINT64_LIST_PACKED
-
INT32_LIST_PACKED
public static final FieldType INT32_LIST_PACKED
-
FIXED64_LIST_PACKED
public static final FieldType FIXED64_LIST_PACKED
-
FIXED32_LIST_PACKED
public static final FieldType FIXED32_LIST_PACKED
-
BOOL_LIST_PACKED
public static final FieldType BOOL_LIST_PACKED
-
UINT32_LIST_PACKED
public static final FieldType UINT32_LIST_PACKED
-
ENUM_LIST_PACKED
public static final FieldType ENUM_LIST_PACKED
-
SFIXED32_LIST_PACKED
public static final FieldType SFIXED32_LIST_PACKED
-
SFIXED64_LIST_PACKED
public static final FieldType SFIXED64_LIST_PACKED
-
SINT32_LIST_PACKED
public static final FieldType SINT32_LIST_PACKED
-
SINT64_LIST_PACKED
public static final FieldType SINT64_LIST_PACKED
-
GROUP_LIST
public static final FieldType GROUP_LIST
-
MAP
public static final FieldType MAP
-
-
Field Detail
-
javaType
private final JavaType javaType
-
id
private final int id
-
collection
private final FieldType.Collection collection
-
elementType
private final java.lang.Class<?> elementType
-
primitiveScalar
private final boolean primitiveScalar
-
VALUES
private static final FieldType[] VALUES
-
EMPTY_TYPES
private static final java.lang.reflect.Type[] EMPTY_TYPES
-
-
Constructor Detail
-
FieldType
private FieldType(int id, FieldType.Collection collection, JavaType javaType)
-
-
Method Detail
-
values
public static FieldType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (FieldType c : FieldType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FieldType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
id
public int id()
A reliable unique identifier for this type.
-
getJavaType
public JavaType getJavaType()
Gets theJavaTypefor 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
public boolean isValidForField(java.lang.reflect.Field field)
Indicates whether or not thisFieldTypecan be applied to the givenField.
-
isValidForList
private boolean isValidForList(java.lang.reflect.Field field)
-
forId
public static FieldType forId(int id)
Looks up the appropriateFieldTypeby it's identifier.- Returns:
- the
FieldTypeornullif not found.
-
getGenericSuperList
private static java.lang.reflect.Type getGenericSuperList(java.lang.Class<?> clazz)
Given a class, finds a generic super class or interface that extendsList.- Returns:
- the generic super class/interface, or
nullif not found.
-
getListParameter
private static java.lang.reflect.Type getListParameter(java.lang.Class<?> clazz, java.lang.reflect.Type[] realTypes)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. Ifclazzdoes not have any generic parameters, this list should be empty.- Returns:
- the
Listparameter.
-
-