8515f572452677b0fad3a4a21a0d5986b3e71ea4
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2021 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.model.basicmodel.xml;
23
24 import java.io.Serializable;
25 import javax.xml.bind.annotation.XmlAccessType;
26 import javax.xml.bind.annotation.XmlAccessorType;
27 import javax.xml.bind.annotation.XmlType;
28 import javax.xml.bind.annotation.adapters.XmlAdapter;
29 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
30
31 /**
32  * This class manages marshaling and unmarshaling of Apex {@link AxReferenceKey} concepts using JAXB. The local name in
33  * reference keys must have specific handling.
34  */
35 @XmlAccessorType(XmlAccessType.PROPERTY)
36 @XmlType(namespace = "http://www.onap.org/policy/apex-pdp")
37 public class AxReferenceKeyAdapter extends XmlAdapter<String, AxReferenceKey> implements Serializable {
38
39     private static final long serialVersionUID = -3480405083900107029L;
40
41     /**
42      * {@inheritDoc}.
43      */
44     @Override
45     public final String marshal(final AxReferenceKey key) throws Exception {
46         return key.getLocalName();
47     }
48
49     /**
50      * {@inheritDoc}.
51      */
52     @Override
53     public final AxReferenceKey unmarshal(final String key) throws Exception {
54         final var axReferenceKey = new AxReferenceKey();
55         axReferenceKey.setLocalName(key);
56         return axReferenceKey;
57     }
58 }