Future-proof OvsdbTypesIdResolver
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / notation / json / OvsdbTypesIdResolver.java
1 /*
2  * Copyright (c) 2013, 2015 Red Hat, 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
9 package org.opendaylight.ovsdb.lib.notation.json;
10
11 import com.fasterxml.jackson.annotation.JsonTypeInfo;
12 import com.fasterxml.jackson.databind.JavaType;
13 import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
14 import com.fasterxml.jackson.databind.type.TypeFactory;
15
16 import org.opendaylight.ovsdb.lib.notation.OvsdbSet;
17 import org.opendaylight.ovsdb.lib.notation.UUID;
18
19 public  class OvsdbTypesIdResolver extends TypeIdResolverBase {
20
21     private JavaType baseType;
22
23     @Override
24     public void init(JavaType bt) {
25         this.baseType = bt;
26     }
27
28     @Override
29     public String idFromValue(Object value) {
30         throw new UnsupportedOperationException("not yet done");
31     }
32
33     @Override
34     public String idFromValueAndType(Object value, Class<?> suggestedType) {
35         throw new UnsupportedOperationException("not yet done");
36     }
37
38     @Override
39     public String idFromBaseType() {
40         throw new UnsupportedOperationException("not yet done");
41     }
42
43     @Override
44     public JavaType typeFromId(String id) {
45         if ("set".equals(id)) {
46             return TypeFactory.defaultInstance().constructCollectionType(OvsdbSet.class, Object.class);
47         } else if ("uuid".equals(id) || "named-uuid".equals(id)) {
48             return TypeFactory.defaultInstance().constructType(UUID.class);
49         }
50         return null;
51     }
52
53     @Override
54     public JsonTypeInfo.Id getMechanism() {
55         throw new UnsupportedOperationException("not yet done");
56     }
57 }