Class ThriftCatalog

java.lang.Object
io.airlift.drift.codec.metadata.ThriftCatalog

@ThreadSafe public final class ThriftCatalog extends Object
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 Details

  • Method Details

    • addThriftType

      public void addThriftType(ThriftType thriftType)
    • addDefaultCoercions

      public void addDefaultCoercions(Class<?> coercionsClass)
      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

      public TypeCoercion getDefaultCoercion(Type type)
      Gets the default TypeCoercion (and associated ThriftType) for the specified Java type.
    • getThriftType

      public ThriftType getThriftType(Type javaType) throws IllegalArgumentException
      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

      public ThriftType getThriftTypeFromCache(Type javaType)
    • getFieldThriftTypeReference

      public ThriftTypeReference getFieldThriftTypeReference(io.airlift.drift.codec.metadata.FieldMetadata fieldMetadata)
    • getCollectionElementThriftTypeReference

      public ThriftTypeReference getCollectionElementThriftTypeReference(Type javaType)
    • getMapKeyThriftTypeReference

      public ThriftTypeReference getMapKeyThriftTypeReference(Type javaType)
    • getMapValueThriftTypeReference

      public ThriftTypeReference getMapValueThriftTypeReference(Type javaType)
    • getOptionalThriftTypeReference

      public ThriftTypeReference getOptionalThriftTypeReference(Type javaType)
    • isSupportedStructFieldType

      public boolean isSupportedStructFieldType(Type javaType)
    • getThriftProtocolType

      public ThriftProtocolType getThriftProtocolType(Type javaType)
    • isStructType

      public static boolean isStructType(Type javaType)
    • isSupportedArrayComponentType

      public boolean isSupportedArrayComponentType(Class<?> componentType)
    • getThriftEnumMetadata

      public <T extends Enum<T>> ThriftEnumMetadata<?> getThriftEnumMetadata(Class<?> enumClass)
      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

      public <T> ThriftStructMetadata getThriftStructMetadata(Type structType)
      Gets the ThriftStructMetadata for the specified struct class. The struct class must be annotated with @ThriftStruct or @ThriftUnion.
    • getThriftDocumentation

      public static com.google.common.collect.ImmutableList<String> getThriftDocumentation(Class<?> objectClass)
    • getThriftDocumentation

      public static com.google.common.collect.ImmutableList<String> getThriftDocumentation(Method method)
    • getThriftDocumentation

      public static com.google.common.collect.ImmutableList<String> getThriftDocumentation(Field field)
    • getThriftDocumentation

      public static <T extends Enum<T>> com.google.common.collect.ImmutableList<String> getThriftDocumentation(Enum<T> enumConstant)
    • getMethodOrder

      public static Integer getMethodOrder(Method method)