Do not require DataObject for streaming
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / CodecContextFactory.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, 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 package org.opendaylight.mdsal.binding.dom.codec.impl;
9
10 import com.google.common.collect.ImmutableMap;
11 import java.lang.reflect.Method;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.binding.loader.BindingClassLoader;
14 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
15 import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17
18 /**
19  * Immutable factory, which provides access to runtime context, create leaf nodes and provides path argument codecs.
20  *
21  * <p>
22  * During lifetime of factory all calls for same arguments to method must return equal result (not necessary same
23  * instance of result).
24  */
25 sealed interface CodecContextFactory permits BindingCodecContext {
26     /**
27      * Returns immutable runtime context associated with this factory.
28      *
29      * @return runtime context
30      */
31     BindingRuntimeContext getRuntimeContext();
32
33     /**
34      * Returns leaf nodes for supplied data container and parent class.
35      *
36      * @param type Binding type for which leaves should be loaded.
37      * @param schema  Instantiated schema of binding type.
38      * @return Map of local name to leaf node context.
39      */
40     ImmutableMap<Method, ValueNodeCodecContext> getLeafNodes(Class<?> type, EffectiveStatement<?, ?> schema);
41
42     /**
43      * Returns Path argument codec for list item.
44      *
45      * @param listClz Type of list item
46      * @param type Schema of list item
47      * @return Path argument codec for supplied list item.
48      */
49     IdentifiableItemCodec getPathArgumentCodec(Class<?> listClz, ListRuntimeType type);
50
51     /**
52      * Return the codec loader associated with this factory.
53      *
54      * @return A codec loader instance
55      */
56     @NonNull BindingClassLoader getLoader();
57
58     @NonNull DataContainerStreamer<?> getDataContainerStreamer(Class<?> type);
59
60     DataContainerSerializer getEventStreamSerializer(Class<?> type);
61 }