2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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
8 package org.opendaylight.yangtools.yang.data.util.codec;
10 import com.google.common.annotations.Beta;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
14 import org.opendaylight.yangtools.yang.model.api.TypedSchemaNode;
17 * Abstract cache for codecs.
19 * @author Robert Varga
21 * @param <T> Codec type
24 public abstract class CodecCache<T> {
26 * Lookup a complex codec for schema node.
28 * @param schema Schema node
29 * @return Cached codec, or null if no codec is cached.
31 @Nullable public abstract T lookupComplex(TypedSchemaNode schema);
34 * Lookup a simple codec for a type definition.
36 * @param type Type definition
37 * @return Cached codec, or null if no codec is cached.
39 @Nullable public abstract T lookupSimple(TypeDefinition<?> type);
42 * Lookup-or-store a complex codec for a particular schema node.
44 * @param schema Schema node
45 * @param codec Codec to cache
46 * @return Codec instance, either already-cached, or the codec presented as argument.
48 @Nonnull public abstract T getComplex(TypedSchemaNode schema, T codec);
51 * Lookup-or-store a simple codec for a particular schema node.
53 * @param type Type definition
54 * @param codec Codec to cache
55 * @return Codec instance, either already-cached, or the codec presented as argument.
57 @Nonnull public abstract T getSimple(TypeDefinition<?> type, T codec);