Merge "Unit test for ovsdb.southbound.ovsdb.transact"
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepSouthboundUtil.java
1 /*
2  * Copyright (c) 2014 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.ovsdb.hwvtepsouthbound;
9
10 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
11 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public class HwvtepSouthboundUtil {
16
17     private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundUtil.class);
18
19     private static InstanceIdentifierCodec instanceIdentifierCodec;
20
21     private HwvtepSouthboundUtil() {
22         // Prevent instantiating a utility class
23     }
24
25     public static void setInstanceIdentifierCodec(InstanceIdentifierCodec iidc) {
26         instanceIdentifierCodec = iidc;
27     }
28
29     public static InstanceIdentifierCodec getInstanceIdentifierCodec() {
30         return instanceIdentifierCodec;
31     }
32
33     public static String serializeInstanceIdentifier(InstanceIdentifier<?> iid) {
34         return instanceIdentifierCodec.serialize(iid);
35     }
36
37     public static InstanceIdentifier<?> deserializeInstanceIdentifier(String iidString) {
38         InstanceIdentifier<?> result = null;
39         try {
40             result = instanceIdentifierCodec.bindingDeserializer(iidString);
41         } catch (DeserializationException e) {
42             LOG.warn("Unable to deserialize iidString", e);
43         }
44         return result;
45     }
46
47
48 }