Merge "Fix findbugs violations in netconf"
[netconf.git] / netconf / netconf-client / src / main / java / org / opendaylight / netconf / client / conf / NetconfReconnectingClientConfigurationBuilder.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.netconf.client.conf;
9
10 import java.net.InetSocketAddress;
11 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
12 import org.opendaylight.netconf.client.NetconfClientSessionListener;
13 import org.opendaylight.netconf.client.SslHandlerFactory;
14 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
15 import org.opendaylight.protocol.framework.ReconnectStrategy;
16 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
17
18 public final class NetconfReconnectingClientConfigurationBuilder extends NetconfClientConfigurationBuilder {
19
20     private ReconnectStrategyFactory connectStrategyFactory;
21
22     private NetconfReconnectingClientConfigurationBuilder() {
23     }
24
25     public static NetconfReconnectingClientConfigurationBuilder create() {
26         return new NetconfReconnectingClientConfigurationBuilder();
27     }
28
29     @SuppressWarnings("checkstyle:hiddenField")
30     public NetconfReconnectingClientConfigurationBuilder withConnectStrategyFactory(
31             final ReconnectStrategyFactory connectStrategyFactory) {
32         this.connectStrategyFactory = connectStrategyFactory;
33         return this;
34     }
35
36     @Override
37     public NetconfReconnectingClientConfiguration build() {
38         return new NetconfReconnectingClientConfiguration(getProtocol(), getAddress(), getConnectionTimeoutMillis(),
39                 getAdditionalHeader(), getSessionListener(), getReconnectStrategy(), connectStrategyFactory,
40                 getAuthHandler(), getSslHandlerFactory());
41     }
42
43     // Override setter methods to return subtype
44
45     @Override
46     public NetconfReconnectingClientConfigurationBuilder withAddress(final InetSocketAddress address) {
47         return (NetconfReconnectingClientConfigurationBuilder) super.withAddress(address);
48     }
49
50     @Override
51     public NetconfReconnectingClientConfigurationBuilder withConnectionTimeoutMillis(
52             final long connectionTimeoutMillis) {
53         return (NetconfReconnectingClientConfigurationBuilder)
54                 super.withConnectionTimeoutMillis(connectionTimeoutMillis);
55     }
56
57     @Override
58     public NetconfReconnectingClientConfigurationBuilder withAdditionalHeader(
59             final NetconfHelloMessageAdditionalHeader additionalHeader) {
60         return (NetconfReconnectingClientConfigurationBuilder) super.withAdditionalHeader(additionalHeader);
61     }
62
63     @Override
64     public NetconfReconnectingClientConfigurationBuilder withSessionListener(
65             final NetconfClientSessionListener sessionListener) {
66         return (NetconfReconnectingClientConfigurationBuilder) super.withSessionListener(sessionListener);
67     }
68
69     @Override
70     public NetconfReconnectingClientConfigurationBuilder withReconnectStrategy(
71             final ReconnectStrategy reconnectStrategy) {
72         return (NetconfReconnectingClientConfigurationBuilder) super.withReconnectStrategy(reconnectStrategy);
73     }
74
75     @Override
76     public NetconfReconnectingClientConfigurationBuilder withAuthHandler(final AuthenticationHandler authHandler) {
77         return (NetconfReconnectingClientConfigurationBuilder) super.withAuthHandler(authHandler);
78     }
79
80     @Override
81     public NetconfReconnectingClientConfigurationBuilder withProtocol(
82             NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
83         return (NetconfReconnectingClientConfigurationBuilder) super.withProtocol(clientProtocol);
84     }
85
86     @Override
87     public NetconfReconnectingClientConfigurationBuilder withSslHandlerFactory(
88             final SslHandlerFactory sslHandlerFactory) {
89         return (NetconfReconnectingClientConfigurationBuilder) super.withSslHandlerFactory(sslHandlerFactory);
90     }
91 }