1+ /*
2+ * Copyright 2026 Lambda
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+ package com.lambda.config.serializer
19+
20+ import com.google.gson.JsonDeserializationContext
21+ import com.google.gson.JsonElement
22+ import com.google.gson.JsonObject
23+ import com.google.gson.JsonSerializationContext
24+ import com.lambda.config.Codec
25+ import com.lambda.config.settings.complex.Bind
26+ import java.lang.reflect.Type
27+
28+ object BindCodec : Codec<Bind> {
29+ override fun serialize (src : Bind , typeOfSrc : Type , context : JsonSerializationContext ): JsonElement =
30+ JsonObject ().apply {
31+ addProperty(" key" , src.key)
32+ addProperty(" modifiers" , src.modifiers)
33+ addProperty(" mouse" , src.mouse)
34+ }
35+
36+ override fun deserialize (json : JsonElement , typeOfT : Type , context : JsonDeserializationContext ) =
37+ json.asJsonObject.let { obj ->
38+ Bind (obj.get(" key" ).asInt, obj.get(" modifiers" ).asInt, obj.get(" mouse" ).asInt)
39+ }
40+ }
0 commit comments