Populate data/ hierarchy
[yangtools.git] / data / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / codec / NoopCodecCache.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.yangtools.yang.data.util.codec;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
12 import org.opendaylight.yangtools.yang.model.api.TypeAware;
13 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
14
15 /**
16  * A no-operation codec cache. This class is thread-safe.
17  *
18  * @author Robert Varga
19  *
20  * @param <T> Codec type
21  */
22 @Beta
23 public final class NoopCodecCache<T> extends CodecCache<T> {
24     private static final NoopCodecCache<?> INSTANCE = new NoopCodecCache<>();
25
26     private NoopCodecCache() {
27         // Hidden
28     }
29
30     @SuppressWarnings("unchecked")
31     public static <T> NoopCodecCache<T> getInstance() {
32         return (NoopCodecCache<T>) INSTANCE;
33     }
34
35     @Override
36     <S extends SchemaNode & TypeAware> T lookupComplex(final S schema) {
37         return null;
38     }
39
40     @Override
41     T lookupSimple(final TypeDefinition<?> type) {
42         return null;
43     }
44
45     @Override
46     T getSimple(final TypeDefinition<?> type, final T codec) {
47         return codec;
48     }
49
50     @Override
51     <S extends SchemaNode & TypeAware> T getComplex(final S schema, final T codec) {
52         return codec;
53     }
54 }