Re-integrate ssh client
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / client / NetconfClientBuilder.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.nettyutil.handler.ssh.client;
9
10 import static com.google.common.base.Verify.verify;
11
12 import com.google.common.annotations.Beta;
13 import org.opendaylight.netconf.shaded.sshd.client.ClientBuilder;
14 import org.opendaylight.netconf.shaded.sshd.client.SshClient;
15
16 /**
17  * A {@link ClientBuilder} which builds {@link NetconfSshClient} instances.
18  */
19 @Beta
20 public class NetconfClientBuilder extends ClientBuilder {
21     @Override
22     public NetconfSshClient build() {
23         final SshClient client = super.build();
24         verify(client instanceof NetconfSshClient, "Unexpected client %s", client);
25         return (NetconfSshClient) client;
26     }
27
28     @Override
29     protected ClientBuilder fillWithDefaultValues() {
30         if (factory == null) {
31             factory = NetconfSshClient.DEFAULT_NETCONF_SSH_CLIENT_FACTORY;
32         }
33         return super.fillWithDefaultValues();
34     }
35 }