658c4ddf8ae1cc9446d73ddca23e890e02f21093
[honeycomb.git] / lisp / lisp2vpp / src / main / java / io / fd / honeycomb / lisp / translate / read / trait / SubtableReader.java
1 /*
2  * Copyright (c) 2015 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.lisp.translate.read.trait;
18
19
20 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L2;
21 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.MapLevel.L3;
22 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams.SubtableDumpParamsBuilder;
23
24 import com.google.common.base.Optional;
25 import io.fd.honeycomb.lisp.translate.read.dump.executor.params.SubtableDumpParams;
26 import io.fd.honeycomb.translate.ModificationCache;
27 import io.fd.honeycomb.translate.read.ReadFailedException;
28 import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
29 import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
30 import javax.annotation.Nonnull;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
32 import org.opendaylight.yangtools.yang.binding.ChildOf;
33 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34
35 /**
36  * Provides common logic for reading Eid subtables
37  */
38 public interface SubtableReader {
39
40     SubtableDumpParams L2_PARAMS = new SubtableDumpParamsBuilder().setL2(L2).build();
41     SubtableDumpParams L3_PARAMS = new SubtableDumpParamsBuilder().setL2(L3).build();
42
43     default Optional<LispEidTableMapDetailsReplyDump> readSubtable(
44             @Nonnull final DumpCacheManager<LispEidTableMapDetailsReplyDump, SubtableDumpParams> dumpManager,
45             @Nonnull final String cacheKey,
46             @Nonnull final ModificationCache cache,
47             @Nonnull final InstanceIdentifier<? extends ChildOf<VniTable>> id,
48             @Nonnull final SubtableDumpParams params) throws ReadFailedException {
49         return dumpManager.getDump(id, cacheKey, cache, params);
50     }
51 }