2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import java.math.BigDecimal;
16 import java.math.BigInteger;
17 import java.util.HashMap;
21 public enum ValueType {
34 private static Map<Class, ValueType> types = new HashMap<>();
37 types.put(String.class, STRING_TYPE);
38 types.put(Byte.class, BYTE_TYPE);
39 types.put(Integer.class, INT_TYPE);
40 types.put(Long.class, LONG_TYPE);
41 types.put(Boolean.class, BOOL_TYPE);
42 types.put(QName.class, QNAME_TYPE);
43 types.put(Set.class, BITS_TYPE);
44 types.put(YangInstanceIdentifier.class, YANG_IDENTIFIER_TYPE);
45 types.put(Short.class,SHORT_TYPE);
46 types.put(BigInteger.class, BIG_INTEGER_TYPE);
47 types.put(BigDecimal.class, BIG_DECIMAL_TYPE);
50 public static final ValueType getSerializableType(Object node){
51 Preconditions.checkNotNull(node, "node should not be null");
53 ValueType type = types.get(node.getClass());
56 } else if(node instanceof Set){
60 throw new IllegalArgumentException("Unknown value type " + node.getClass().getSimpleName());