Interface TypeSignature

All Known Implementing Classes:
ContainerTypeSignature, DescriptiveTypeSignature, MapTypeSignature

@UnstableApi public interface TypeSignature
Type signature of a method parameter, a method return value or a struct/exception field. A type signature can be represented as a string in one of the following forms:
  • Base types: "{type name}"
    • "i64"
    • "double"
    • "string"
  • Container types: "{type name}<{element type signature}[, {element type signature}]*>"
    • "list<i32>"
    • "repeated<set<string>>"
    • "map<string, com.example.FooStruct>"
    • "tuple<i8, string, double>"
  • Named types (enums, structs and exceptions): "{fully qualified type name}"
    • "com.example.FooStruct"
  • Unresolved types: "?{type name}"
    • "?BarStruct"
    • "?com.example.BarStruct"
  • Method Details

    • ofBase

      static TypeSignature ofBase(String baseTypeName)
      Creates a new type signature for a base type.
      Throws:
      IllegalArgumentException - if the specified type name is not valid
    • ofContainer

      static ContainerTypeSignature ofContainer(String containerTypeName, TypeSignature... elementTypeSignatures)
      Creates a new container type with the specified container type name and the type signatures of the elements it contains.
      Throws:
      IllegalArgumentException - if the specified type name is not valid or elementTypeSignatures is empty.
    • ofContainer

      static ContainerTypeSignature ofContainer(String containerTypeName, Iterable<TypeSignature> elementTypeSignatures)
      Creates a new container type with the specified container type name and the type signatures of the elements it contains.
      Throws:
      IllegalArgumentException - if the specified type name is not valid or elementTypeSignatures is empty.
    • ofList

      static ContainerTypeSignature ofList(TypeSignature elementTypeSignature)
      Creates a new type signature for the list with the specified element type signature. This method is a shortcut for:
      
       ofContainer("list", elementTypeSignature);
       
    • ofSet

      static ContainerTypeSignature ofSet(TypeSignature elementTypeSignature)
      Creates a new type signature for the set with the specified element type signature. This method is a shortcut for:
      
       ofContainer("set", elementTypeSignature);
       
    • ofIterable

      static ContainerTypeSignature ofIterable(String iterableTypeName, TypeSignature elementTypeSignature)
      Creates a new container type with the specified container type name and the type signatures of the elements it contains.
      Throws:
      IllegalArgumentException - if the specified type name is not valid or elementTypeSignatures is empty.
    • ofMap

      static MapTypeSignature ofMap(TypeSignature keyTypeSignature, TypeSignature valueTypeSignature)
      Creates a new type signature for the map with the specified key and value type signatures. This method is a shortcut for:
      
       ofMap("map", keyTypeSignature, valueTypeSignature);
       
    • ofOptional

      static ContainerTypeSignature ofOptional(TypeSignature elementTypeSignature)
      Creates a new type signature for the optional type with the specified element type signature.
    • ofStruct

      static DescriptiveTypeSignature ofStruct(Class<?> structType)
      Creates a new struct type signature for the specified type. An Exception type is also created using this method.
    • ofStruct

      static DescriptiveTypeSignature ofStruct(String name, Object typeDescriptor)
      Creates a new struct type signature for the provided name and arbitrary descriptor. An Exception type is also created using this method.
    • ofEnum

      static DescriptiveTypeSignature ofEnum(Class<?> enumType)
      Creates a new enum type signature for the specified type.
    • ofEnum

      static DescriptiveTypeSignature ofEnum(String name, Object enumTypeDescriptor)
      Creates a new enum type signature for the provided name and arbitrary descriptor.
    • ofUnresolved

      static TypeSignature ofUnresolved(String unresolvedTypeName)
      Creates a new unresolved type signature with the specified type name.
    • type

      Returns the TypeSignatureType.
    • name

      String name()
      Returns the name of the type.
    • signature

      default String signature()
      Returns the String representation of this type signature, as described in the class documentation.