Replace Preconditions.CheckNotNull per RequireNonNull
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / controller / config / yang / bgp / rib / impl / BGPPSMImplModule.java
1 /*
2  * Copyright (c) 2016 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.controller.config.yang.bgp.rib.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.opendaylight.controller.config.api.DependencyResolver;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
15 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPBestPathSelection;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
19 import org.opendaylight.yangtools.yang.binding.DataContainer;
20
21 public final class BGPPSMImplModule extends AbstractBGPPSMImplModule {
22     public BGPPSMImplModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
23         super(identifier, dependencyResolver);
24     }
25
26     public BGPPSMImplModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver, BGPPSMImplModule oldModule, AutoCloseable oldInstance) {
27         super(identifier, dependencyResolver, oldModule, oldInstance);
28     }
29
30     private static final class AutoCloseableBestPathSelectionStrategy implements BGPBestPathSelection {
31
32         private final BgpTableType pathFamilyDependency;
33         private final PathSelectionMode strategyFactory;
34
35         AutoCloseableBestPathSelectionStrategy(final BgpTableType pathFamilyDependency, final PathSelectionMode strategyFactory) {
36             this.pathFamilyDependency = requireNonNull(pathFamilyDependency);
37             this.strategyFactory = requireNonNull(strategyFactory);
38         }
39
40         @Override
41         public void close() throws Exception {
42             this.strategyFactory.close();
43         }
44
45         @Override
46         public Class<? extends AddressFamily> getAfi() {
47             return this.pathFamilyDependency.getAfi();
48         }
49
50         @Override
51         public Class<? extends SubsequentAddressFamily> getSafi() {
52             return this.pathFamilyDependency.getSafi();
53         }
54
55         @Override
56         public Class<? extends DataContainer> getImplementedInterface() {
57             return BGPBestPathSelection.class;
58         }
59
60         @Override
61         public PathSelectionMode getStrategy() {
62             return this.strategyFactory;
63         }
64     }
65
66     @Override
67     public void customValidation() {
68     }
69
70     @Override
71     public java.lang.AutoCloseable createInstance() {
72         return new AutoCloseableBestPathSelectionStrategy(getPathAddressFamilyDependency(), getPathSelectionModeDependency());
73     }
74 }