BUG-731 Fix sonar warnings present in code for BUG-338
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPServerSessionNegotiatorFactory.java
1 /*
2  * Copyright (c) 2014 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.protocol.bgp.rib.impl;
9
10 import com.google.common.base.Preconditions;
11
12 import io.netty.channel.Channel;
13 import io.netty.util.Timer;
14 import io.netty.util.concurrent.Promise;
15
16 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
17 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
18 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionValidator;
19 import org.opendaylight.protocol.framework.SessionListenerFactory;
20 import org.opendaylight.protocol.framework.SessionNegotiator;
21 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
22 import org.opendaylight.yangtools.yang.binding.Notification;
23
24 public final class BGPServerSessionNegotiatorFactory implements SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> {
25     private final Timer timer;
26     private final BGPSessionValidator validator;
27     private final BGPPeerRegistry registry;
28
29     public BGPServerSessionNegotiatorFactory(final Timer timer, final BGPSessionValidator sessionValidator, final BGPPeerRegistry registry) {
30         this.registry = registry;
31         this.timer = Preconditions.checkNotNull(timer);
32         this.validator = Preconditions.checkNotNull(sessionValidator);
33     }
34
35     @Override
36     public SessionNegotiator<BGPSessionImpl> getSessionNegotiator(final SessionListenerFactory<BGPSessionListener> factory,
37             final Channel channel, final Promise<BGPSessionImpl> promise) {
38         return new BGPServerSessionNegotiator(this.timer, promise, channel, registry, validator);
39     }
40 }