2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.translate.read;
19 import com.google.common.annotations.Beta;
20 import java.util.Collections;
21 import java.util.List;
22 import javax.annotation.Nonnull;
23 import org.opendaylight.yangtools.concepts.Builder;
24 import org.opendaylight.yangtools.yang.binding.DataObject;
25 import org.opendaylight.yangtools.yang.binding.Identifiable;
26 import org.opendaylight.yangtools.yang.binding.Identifier;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 * List reader, allowing read of all the elements.
32 * @param <D> Specific DataObject derived type, that is handled by this reader
35 public interface ListReader
36 <D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends Reader<D, B> {
39 * Read all elements in this list.
41 * @param id Wildcarded identifier of list managed by this reader
42 * @param ctx Read context
44 * @return List of all entries in this list
45 * @throws ReadFailedException if read was unsuccessful
48 List<D> readList(@Nonnull final InstanceIdentifier<D> id, @Nonnull final ReadContext ctx)
49 throws ReadFailedException;
52 * Get IDs for all entries in the list.
54 List<K> getAllIds(@Nonnull InstanceIdentifier<D> id, @Nonnull ReadContext ctx)
55 throws ReadFailedException;
58 * Merge read data into provided parent builder.
60 void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final List<D> readData);
63 default void merge(@Nonnull final Builder<? extends DataObject> parentBuilder, @Nonnull final D readValue) {
64 merge(parentBuilder, Collections.singletonList(readValue));