/*
 * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.protocol.bgp.rib.impl.spi;

import javax.annotation.Nullable;
import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;

public interface RIBSupportContextRegistry {
    /**
     * Acquire a RIB Support for a AFI/SAFI combination.
     *
     * @param key AFI/SAFI key
     * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
     */
    @Nullable
    <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
        R extends Route & ChildOf<? super S> & Identifiable<I>,
        I extends Identifier<R>> RIBSupport<C, S, R, I> getRIBSupport(TablesKey key);

    /**
     * Acquire a RIB Support Context for a AFI/SAFI combination.
     *
     * @param key AFI/SAFI key
     * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
     */
    @Nullable
    RIBSupportContext getRIBSupportContext(TablesKey key);

    /**
     * Acquire a RIB Support Context for a AFI/SAFI combination.
     *
     * @param key Tables key with AFI/SAFI key
     * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
     */
    @Nullable
    RIBSupportContext getRIBSupportContext(NodeIdentifierWithPredicates key);

    /**
     * Acquire a RIB Support Context for a AFI/SAFI combination.
     *
     * @param key Tables key with AFI/SAFI key
     * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
     */
    @Nullable
    default <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
        R extends Route & ChildOf<? super S> & Identifiable<I>,
        I extends Identifier<R>> RIBSupport<C, S, R, I> getRIBSupport(NodeIdentifierWithPredicates key) {
        final RIBSupportContext support = getRIBSupportContext(key);
        return support == null ? null : support.getRibSupport();
    }
}

@@ -1828,32 +1828,48 @@
    * @param key 
+Tables key with 
 AFI/SAFI key%0A   
@@ -1857,32 +1857,32 @@
 th AFI/SAFI key%0A
-
      * @return R
@@ -1963,32 +1963,305 @@
   @Nullable%0A    
+default %3CC extends Routes & DataObject & ChoiceIn%3CTables%3E, S extends ChildOf%3C? super C%3E,%0A        R extends Route & ChildOf%3C? super S%3E & Identifiable%3CI%3E,%0A        I extends Identifier%3CR%3E%3E RIBSupport%3CC, S, R, I%3E getRIBSupport(NodeIdentifierWithPredicates key) %7B%0A        final 
 RIBSupportContex
@@ -2253,32 +2253,42 @@
 IBSupportContext
+ support =
  getRIBSupportCo
@@ -2293,31 +2293,92 @@
 Context(
-TablesKey key);
+key);%0A        return support == null ? null : support.getRibSupport();%0A    %7D
 %0A%0A    /*
@@ -2469,32 +2469,16 @@
 ram key 
-Tables key with 
 AFI/SAFI
@@ -2631,36 +2631,17 @@
 ext(
-NodeIdentifierWithPredicates
+TablesKey
  key
@@ -2881,405 +2881,80 @@
     
-default %3CC extends Routes & DataObject & ChoiceIn%3CTables%3E, S extends ChildOf%3C? super C%3E,%0A        R extends Route & ChildOf%3C? super S%3E & Identifiable%3CI%3E,%0A        I extends Identifier%3CR%3E%3E RIBSupport%3CC, S, R, I%3E getRIBSupport(NodeIdentifierWithPredicates key) %7B%0A        final RIBSupportContext support = getRIBSupportContext(key);%0A        return support == null ? null : support.getRibSupport();%0A    %7D
+RIBSupportContext getRIBSupportContext(NodeIdentifierWithPredicates key);
 %0A%7D%0A

Fix checkstyle in RIBSupportContextRegistry