HONEYCOMB-106 - Support for generic cache management
[honeycomb.git] / v3po / translate-api / src / main / java / io / fd / honeycomb / v3po / translate / read / registry / ReaderRegistry.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.v3po.translate.read.registry;
18
19 import com.google.common.annotations.Beta;
20 import com.google.common.base.Optional;
21 import com.google.common.collect.Multimap;
22 import io.fd.honeycomb.v3po.translate.read.ReadContext;
23 import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
24 import javax.annotation.Nonnull;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27
28 /**
29  * Simple delegating reader suitable as a holder for all other root readers, providing readAll feature.
30  */
31 @Beta
32 public interface ReaderRegistry {
33
34     /**
35      * Performs read on all registered root readers and merges the results into a Multimap. Keys represent identifiers
36      * for root DataObjects from the data tree modeled by YANG.
37      *
38      * @param ctx Read context
39      *
40      * @return multimap that preserves deterministic iteration order across non-distinct key values
41      * @throws ReadFailedException if read was unsuccessful
42      */
43     @Nonnull
44     Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> readAll(@Nonnull final ReadContext ctx)
45             throws ReadFailedException;
46
47     /**
48      * Reads data identified by id.
49      *
50      * @param id unique identifier of subtree to be read. The subtree must contain managed data object type. For
51      *           identifiers pointing below node managed by this reader, it's reader's responsibility to filter out the
52      *           right node or to delegate the read to a child reader.
53      * @param ctx Read context
54      *
55      * @return List of DataObjects identified by id. If the ID points to a single node, it will be wrapped in a list
56      * @throws ReadFailedException if read was unsuccessful
57      */
58     @Nonnull
59     Optional<? extends DataObject> read(@Nonnull InstanceIdentifier<? extends DataObject> id,
60                                         @Nonnull ReadContext ctx)
61             throws ReadFailedException;
62 }