BUG-7983: extract codec caching from JSONCodecFactory
[yangtools.git] / yang / 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 javax.annotation.concurrent.ThreadSafe;
12 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
13 import org.opendaylight.yangtools.yang.model.api.TypedSchemaNode;
14
15 /**
16  * A no-operation codec cache.
17  *
18  * @author Robert Varga
19  *
20  * @param <T> Codec type
21  */
22 @Beta
23 @ThreadSafe
24 public final class NoopCodecCache<T> extends CodecCache<T> {
25     private static final NoopCodecCache<?> INSTANCE = new NoopCodecCache<>();
26
27     private NoopCodecCache() {
28         // Hidden
29     }
30
31     @SuppressWarnings("unchecked")
32     public static <T> NoopCodecCache<T> getInstance() {
33         return (NoopCodecCache<T>) INSTANCE;
34     }
35
36     @Override
37     public T lookupComplex(final TypedSchemaNode schema) {
38         return null;
39     }
40
41     @Override
42     public T lookupSimple(final TypeDefinition<?> type) {
43         return null;
44     }
45
46     @Override
47     public T getSimple(final TypeDefinition<?> type, final T codec) {
48         return codec;
49     }
50
51     @Override
52     public T getComplex(final TypedSchemaNode schema, final T codec) {
53         return codec;
54     }
55 }