Parameters

abstract class Parameters(val data: ParameterStorage = HashMap())(source)

Additional parameters for endpoints.

Endpoints declare mandatory parameters, such as the identifier of the resource. This abstract class allows to declare additional parameters in a type-safe manner.

Usage

In common code, declare a class that inherits from Parameters, and use it to declare the name and type of the available parameters:

class MyRequestParameters(data: ParameterStorage) : Parameters(data) {
var param1: String? by parameter()
var isSubscribed: Boolean by parameter("is_subscribed", default = false)
}

To create a new parameter bundle, use the helper buildParameters function:

val example = buildParameters(::MyRequestParameters) {
param1 = "value"
isSubscribed = true
}

The values can be accessed in a type-safe manner:

println(example.param1)

The values can also be accessed via their string representation:

println(example.data["param1"])

Inheritors

Constructors

Link copied to clipboard
constructor(data: ParameterStorage = HashMap())

Types

Link copied to clipboard
object Empty : Parameters

The default parameter instance.

Link copied to clipboard
class Parameter<T>(val name: String, val defaultValue: T?)

A declared query parameter in an API schema.

Link copied to clipboard

Internal type used by the parameter declaration syntax.

Properties

Link copied to clipboard

Internal string representation of the parameters.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String