-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocalNodeState.kt
More file actions
76 lines (63 loc) · 1.85 KB
/
LocalNodeState.kt
File metadata and controls
76 lines (63 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport",
)
package de.gesellix.docker.remote.api
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Current local status of this node.
*
* Values: EMPTY,Inactive,Pending,Active,Error,Locked
*/
@JsonClass(generateAdapter = false)
enum class LocalNodeState(
val value: kotlin.String,
) {
@Json(name = "")
EMPTY(""),
@Json(name = "inactive")
Inactive("inactive"),
@Json(name = "pending")
Pending("pending"),
@Json(name = "active")
Active("active"),
@Json(name = "error")
Error("error"),
@Json(name = "locked")
Locked("locked"),
;
/**
* Override [toString()] to avoid using the enum variable name as the value, and instead use
* the actual value defined in the API spec file.
*
* This solves a problem when the variable name and its value are different, and ensures that
* the client sends the correct enum values to the server always.
*/
override fun toString(): kotlin.String = value
companion object {
/**
* Converts the provided [data] to a [String] on success, null otherwise.
*/
fun encode(data: kotlin.Any?): kotlin.String? = if (data is LocalNodeState) "$data" else null
/**
* Returns a valid [LocalNodeState] for [data], null otherwise.
*/
fun decode(data: kotlin.Any?): LocalNodeState? =
data?.let {
val normalizedData = "$it".lowercase()
entries.firstOrNull { value ->
it == value || normalizedData == "$value".lowercase()
}
}
}
}