Variable
The bridge between ParameterSpec and PropertySpec.
Last updated
The bridge between ParameterSpec and PropertySpec.
Last updated
ParameterSpec and PropertySpec are very similar:
Although they have more fields, these are the ones KotlinPoetDSL supports before V0.2.
Because they are this similar it would make sense to pass around a type that has the commonalities of both the classes. In KotlinPoetDSL, this class is called Variable.
There are 3 function-names: of
, valOf
, varOf
. These can all be invoked the same way. Therefor I show below only using valOf
.
for the vararg:
Slightly interoperable, but will be improved in V0.2
In V0.1 the variables can't be used. In V0.2, the variables can be used interchangeable with ParamSpec and PropertySpec.
The spec passed to the constructor will be returned, so with it's unsuported fields.
On the other hand, annotations are not yet support by KotlinPoetDSL, so when you go from one type to another (paramSpec.toVariable().toPropertySpec()
), the annotations are not preserved.
ParameterSpec
PropertySpec
name
name
modifiers
modifiers
type
type
defaultValue
initializer
null
mutable: Boolean