Package com.linecorp.armeria.server.docs
Class TypeSignature
java.lang.Object
com.linecorp.armeria.server.docs.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 Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
boolean
isBase()
Returnstrue
if this type signature represents a base type.boolean
Returnstrue
if this type signature represents a container type.boolean
isNamed()
Returnstrue
if this type signature represents a named type.boolean
Returnstrue
if this type signature represents an unresolved type.name()
Returns the name of the type.Returns the descriptor of the type if and only if this type signature represents a named type.static TypeSignature
Creates a new type signature for a base type.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.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.static TypeSignature
ofList(TypeSignature elementTypeSignature)
Creates a new type signature for the list with the specified element type signature.static TypeSignature
Creates a new type signature for the list with the specified named element type.static TypeSignature
ofMap(TypeSignature keyTypeSignature, TypeSignature valueTypeSignature)
Creates a new type signature for the map with the specified key and value type signatures.static TypeSignature
Creates a new type signature for the map with the specified named key and value types.static TypeSignature
Creates a new named type signature for the specified type.static TypeSignature
Creates a new named type signature for the provided name and arbitrary descriptor.static TypeSignature
ofSet(TypeSignature elementTypeSignature)
Creates a new type signature for the set with the specified element type signature.static TypeSignature
Creates a new type signature for the set with the specified named element type.static TypeSignature
ofUnresolved(String unresolvedTypeName)
Creates a new unresolved type signature with the specified type name.Returns theString
representation of this type signature, as described in the class documentation.toString()
Returns the list of the type parameters of this type signature.
-
Method Details
-
ofBase
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 orelementTypeSignatures
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 orelementTypeSignatures
is empty.
-
ofList
Creates a new type signature for the list with the specified element type signature. This method is a shortcut for:ofContainer("list", elementTypeSignature);
-
ofList
Creates a new type signature for the list with the specified named element type. This method is a shortcut for:ofList(ofNamed(namedElementType));
-
ofSet
Creates a new type signature for the set with the specified element type signature. This method is a shortcut for:ofContainer("set", elementTypeSignature);
-
ofSet
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
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
Creates a new named type signature for the specified type. -
ofNamed
Creates a new named type signature for the provided name and arbitrary descriptor. -
ofUnresolved
Creates a new unresolved type signature with the specified type name. -
name
Returns the name of the type. -
namedTypeDescriptor
Returns the descriptor of the type if and only if this type signature represents a named type. For reflection-basedDocServicePlugin
s, this will probably be aClass
, but other plugins may use an actual instance with descriptor information. -
typeParameters
Returns the list of the type parameters of this type signature. -
signature
Returns theString
representation of this type signature, as described in the class documentation. -
isBase
public boolean isBase()Returnstrue
if this type signature represents a base type. -
isContainer
public boolean isContainer()Returnstrue
if this type signature represents a container type. -
isNamed
public boolean isNamed()Returnstrue
if this type signature represents a named type. -
isUnresolved
public boolean isUnresolved()Returnstrue
if this type signature represents an unresolved type. -
equals
-
hashCode
public int hashCode() -
toString
-