Skip to content

Package: KuraAssets

KuraAssets

nameinstructionbranchcomplexitylinemethod
KuraAssets()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getAssets()
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
readJsonNode(JsonNode)
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
setAssets(List)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
writeJsonNode(JsonGenerator)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.call.kura.model.asset;
14:
15: import java.io.IOException;
16: import java.util.ArrayList;
17: import java.util.Iterator;
18: import java.util.List;
19:
20: import org.eclipse.kapua.KapuaException;
21:
22: import com.fasterxml.jackson.core.JsonGenerator;
23: import com.fasterxml.jackson.databind.JsonNode;
24:
25: /**
26: * {@link KuraAssets} list definition.
27: *
28: * @since 1.0.0
29: */
30: public class KuraAssets {
31:
32: private List<KuraAsset> assets;
33:
34: /**
35: * Get the assets list
36: *
37: * @return
38: *
39: * @since 1.0.0
40: */
41: public List<KuraAsset> getAssets() {
42:• if (assets == null) {
43: assets = new ArrayList<>();
44: }
45:
46: return assets;
47: }
48:
49: /**
50: * Set the assets list
51: *
52: * @param assets
53: *
54: * @since 1.0.0
55: */
56: public void setAssets(List<KuraAsset> assets) {
57: this.assets = assets;
58: }
59:
60: /**
61: * Parse a {@link JsonNode} that represent the {@link KuraAssets} object.
62: *
63: * @param jsonKuraAssets
64: * The {@link JsonNode} to parse
65: * @return The parsed {@link KuraAssets} result.
66: *
67: * @throws KapuaException
68: *
69: * @since 1.0.0
70: */
71: public static KuraAssets readJsonNode(JsonNode jsonKuraAssets) throws KapuaException {
72:
73: KuraAssets kuraAssets = new KuraAssets();
74:
75: Iterator<JsonNode> jsonNodeIterator = jsonKuraAssets.elements();
76:• while (jsonNodeIterator.hasNext()) {
77: JsonNode jsonNode = jsonNodeIterator.next();
78: kuraAssets.getAssets().add(KuraAsset.readJsonNode(jsonNode));
79: }
80:
81: return kuraAssets;
82: }
83:
84: /**
85: * Serialize {@code this} {@link KuraAssets} into json using the given {@link JsonGenerator}.
86: *
87: * @param jsonGenerator
88: * The {@link JsonGenerator} to put serialized {@link KuraAssets}.
89: * @throws IOException
90: * @since 1.0.0
91: */
92: public void writeJsonNode(JsonGenerator jsonGenerator) throws IOException {
93:
94: jsonGenerator.writeStartArray();
95:• for (KuraAsset kuraAsset : getAssets()) {
96: kuraAsset.writeJsonNode(jsonGenerator);
97: }
98: jsonGenerator.writeEndArray();
99:
100: }
101: }