|
| 1 | +/* |
| 2 | + * Source++, the continuous feedback platform for developers. |
| 3 | + * Copyright (C) 2022 CodeBrig, Inc. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package spp.protocol.instrument.variable |
| 18 | + |
| 19 | +import io.vertx.codegen.annotations.DataObject |
| 20 | +import io.vertx.core.json.JsonObject |
| 21 | + |
| 22 | +/** |
| 23 | + * Allows for fine-grained control over the serialization of [LiveVariable]s. |
| 24 | + */ |
| 25 | +@DataObject |
| 26 | +data class LiveVariableControl( |
| 27 | + val maxObjectDepth: Int? = null, |
| 28 | + val maxObjectSize: Int? = null, |
| 29 | + val maxCollectionLength: Int? = null, |
| 30 | + val variableTypeConfig: Map<String, LiveVariableControl> = emptyMap(), |
| 31 | + val variableNameConfig: Map<String, LiveVariableControl> = emptyMap() |
| 32 | +) { |
| 33 | + constructor(json: JsonObject) : this( |
| 34 | + maxObjectDepth = json.getInteger("maxObjectDepth"), |
| 35 | + maxObjectSize = json.getInteger("maxObjectSize"), |
| 36 | + maxCollectionLength = json.getInteger("maxCollectionLength"), |
| 37 | + variableTypeConfig = json.getJsonObject("variableTypeConfig") |
| 38 | + .associate { it.key to LiveVariableControl(it.value as JsonObject) }, |
| 39 | + variableNameConfig = json.getJsonObject("variableNameConfig") |
| 40 | + .associate { it.key to LiveVariableControl(it.value as JsonObject) } |
| 41 | + ) |
| 42 | + |
| 43 | + fun toJson(): JsonObject { |
| 44 | + return JsonObject.mapFrom(this) |
| 45 | + } |
| 46 | +} |
0 commit comments