Split Restconf implementations (draft02 and RFC) - Application
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / parser / IdentifierCodec.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.parser;
9
10 import org.opendaylight.restconf.parser.builder.YangInstanceIdentifierDeserializer;
11 import org.opendaylight.restconf.parser.builder.YangInstanceIdentifierSerializer;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14
15 /**
16  * Codec for identifier to serialize {@link YangInstanceIdentifier} to {@link String} and deserialize
17  * {@link String} to {@link YangInstanceIdentifier}.
18  *
19  * @deprecated move to splitted module restconf-nb-rfc8040
20  */
21 @Deprecated
22 public final class IdentifierCodec {
23
24     private IdentifierCodec() {
25         throw new UnsupportedOperationException("Util class.");
26     }
27
28     public static String serialize(final YangInstanceIdentifier data, final SchemaContext schemaContext) {
29         return YangInstanceIdentifierSerializer.create(schemaContext, data);
30     }
31
32     public static YangInstanceIdentifier deserialize(final String data, final SchemaContext schemaContext) {
33         if (data == null) {
34             return YangInstanceIdentifier.builder().build();
35         }
36         return YangInstanceIdentifier.create(YangInstanceIdentifierDeserializer.create(schemaContext, data));
37     }
38 }