Package io.airlift.drift.codec.metadata
Class ThriftCatalog
java.lang.Object
io.airlift.drift.codec.metadata.ThriftCatalog
ThriftCatalog contains the metadata for all known structs, enums and type coercions. Since,
metadata extraction can be very expensive, and only single instance of the catalog should be
created.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultCoercions(Class<?> coercionsClass) Add the @ToThrift and @FromThrift coercions in the specified class to this catalog.voidaddThriftType(ThriftType thriftType) getCollectionElementThriftTypeReference(Type javaType) getDefaultCoercion(Type type) Gets the default TypeCoercion (and associated ThriftType) for the specified Java type.getFieldThriftTypeReference(io.airlift.drift.codec.metadata.FieldMetadata fieldMetadata) getMapKeyThriftTypeReference(Type javaType) getMapValueThriftTypeReference(Type javaType) static IntegergetMethodOrder(Method method) getOptionalThriftTypeReference(Type javaType) static com.google.common.collect.ImmutableList<String>getThriftDocumentation(Class<?> objectClass) getThriftDocumentation(Enum<T> enumConstant) static com.google.common.collect.ImmutableList<String>getThriftDocumentation(Field field) static com.google.common.collect.ImmutableList<String>getThriftDocumentation(Method method) <T extends Enum<T>>
ThriftEnumMetadata<?>getThriftEnumMetadata(Class<?> enumClass) Gets the ThriftEnumMetadata for the specified enum class.getThriftProtocolType(Type javaType) getThriftStructMetadata(Type structType) Gets the ThriftStructMetadata for the specified struct class.getThriftType(Type javaType) Gets the ThriftType for the specified Java type.getThriftTypeFromCache(Type javaType) static booleanisStructType(Type javaType) booleanisSupportedArrayComponentType(Class<?> componentType) booleanisSupportedStructFieldType(Type javaType)
-
Constructor Details
-
ThriftCatalog
public ThriftCatalog() -
ThriftCatalog
-
-
Method Details
-
addThriftType
-
addDefaultCoercions
Add the @ToThrift and @FromThrift coercions in the specified class to this catalog. All coercions must be symmetrical, so every @ToThrift method must have a corresponding @FromThrift method. -
getDefaultCoercion
Gets the default TypeCoercion (and associated ThriftType) for the specified Java type. -
getThriftType
Gets the ThriftType for the specified Java type. The native Thrift type for the Java type will be inferred from the Java type, and if necessary type coercions will be applied.- Returns:
- the ThriftType for the specified java type; never null
- Throws:
IllegalArgumentException- if the Java Type can not be coerced to a ThriftType
-
getThriftTypeFromCache
-
getFieldThriftTypeReference
public ThriftTypeReference getFieldThriftTypeReference(io.airlift.drift.codec.metadata.FieldMetadata fieldMetadata) -
getCollectionElementThriftTypeReference
-
getMapKeyThriftTypeReference
-
getMapValueThriftTypeReference
-
getOptionalThriftTypeReference
-
isSupportedStructFieldType
-
getThriftProtocolType
-
isStructType
-
isSupportedArrayComponentType
-
getThriftEnumMetadata
Gets the ThriftEnumMetadata for the specified enum class. If the enum class contains a method annotated with @ThriftEnumValue, the value of this method will be used for the encoded thrift value; otherwise the Enum.ordinal() method will be used. -
getThriftStructMetadata
Gets the ThriftStructMetadata for the specified struct class. The struct class must be annotated with @ThriftStruct or @ThriftUnion. -
getThriftDocumentation
-
getThriftDocumentation
-
getThriftDocumentation
-
getThriftDocumentation
-
getMethodOrder
-