Class TypeSignature

java.lang.Object
com.linecorp.armeria.server.docs.TypeSignature

@UnstableApi public final class TypeSignature extends Object
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

      public 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

      public static TypeSignature 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

      public static TypeSignature 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

      public static TypeSignature 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);
       
    • ofList

      public static TypeSignature ofList(Class<?> namedElementType)
      Creates a new type signature for the list with the specified named element type. This method is a shortcut for:
      
       ofList(ofNamed(namedElementType));
       
    • ofSet

      public static TypeSignature 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);
       
    • ofSet

      public static TypeSignature ofSet(Class<?> namedElementType)
      Creates a new type signature for the set with the specified named element type. This method is a shortcut for:
      
       ofSet(ofNamed(namedElementType));
       
    • ofMap

      public static TypeSignature 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);
       
    • ofMap

      public static TypeSignature ofMap(Class<?> namedKeyType, Class<?> namedValueType)
      Creates a new type signature for the map with the specified named key and value types. This method is a shortcut for:
      
       ofMap(ofNamed(namedKeyType), ofNamed(namedValueType));
       
    • ofNamed

      public static TypeSignature ofNamed(Class<?> namedType)
      Creates a new named type signature for the specified type.
    • ofNamed

      public static TypeSignature ofNamed(String name, Object namedTypeDescriptor)
      Creates a new named type signature for the provided name and arbitrary descriptor.
    • ofUnresolved

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

      public String name()
      Returns the name of the type.
    • namedTypeDescriptor

      @Nullable public @Nullable Object namedTypeDescriptor()
      Returns the descriptor of the type if and only if this type signature represents a named type. For reflection-based DocServicePlugins, this will probably be a Class, but other plugins may use an actual instance with descriptor information.
    • typeParameters

      public List<TypeSignature> typeParameters()
      Returns the list of the type parameters of this type signature.
    • signature

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

      public boolean isBase()
      Returns true if this type signature represents a base type.
    • isContainer

      public boolean isContainer()
      Returns true if this type signature represents a container type.
    • isNamed

      public boolean isNamed()
      Returns true if this type signature represents a named type.
    • isUnresolved

      public boolean isUnresolved()
      Returns true if this type signature represents an unresolved type.
    • equals

      public boolean equals(@Nullable @Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object