blob: fe6fed48405ac6befea6110a0eca88e90c804ce4 (
plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*-
* ============LICENSE_START=======================================================
* ONAP - CCSDK
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import java.util.Map;
/**
* Abstraction of an entity to enable encoding and decoding of properties
* to an abstract properties node tree using YANG based schema.
* This serializer will be used by other data format serializers and will keep
* them abstract from properties nuances thereby enabling quick addition of any
* new data format serializer.
*
* @param <T> type of schema node
* @param <P> schema context of the model
*/
public abstract class PropertiesNodeSerializer<T, P> {
/**
* Schema node from which the property is made.
*/
private T schemaNode;
/**
* Schema context of the model.
*/
private P schemaCtx;
/**
* URL pointing to the schema node.
*/
private String uri;
/**
* Creates the properties node serializer.
*
* @param schemaNode schema node.
* @param schemaCtx schema context
* @param uri URL of the request
*/
public PropertiesNodeSerializer(T schemaNode, P schemaCtx, String uri) {
this.schemaNode = schemaNode;
this.schemaCtx = schemaCtx;
this.uri = uri;
}
/**
* Encodes from properties to properties-node tree.
*
* @param paramMap parameter map
* @throws SvcLogicException fails to encode properties to properties node
* @return properties node
*/
public abstract PropertiesNode encode(Map<String, String> paramMap) throws SvcLogicException;
/**
* Decodes from properties-node to properties map.
*
* @param propertiesNode properties-node
* @return parameter map
* @throws SvcLogicException fails to decode properties node to properties
*/
public abstract Map<String, String> decode(PropertiesNode propertiesNode)
throws SvcLogicException;
/**
* Returns the schema node of the property
*
* @return schema node
*/
public T schemaNode(){
return schemaNode;
}
/**
* Returns the schema context
*
* @return schema node
*/
public P schemaCtx() {
return schemaCtx;
}
/**
* Returns the URI.
*
* @return uri
*/
public String uri() {
return uri;
}
}
|