@Override
protected void sessionUp() {
checkState(loginTime == null, "Session is already up");
- this.loginTime = Instant.now().atZone(ZoneId.systemDefault());
+ loginTime = Instant.now().atZone(ZoneId.systemDefault());
super.sessionUp();
}
* Suitable for close rpc that needs to send ok response before the session is closed.
*/
public void delayedClose() {
- this.delayedClose = true;
+ delayedClose = true;
}
@Override
public ChannelFuture sendMessage(final NetconfMessage netconfMessage) {
final ChannelFuture channelFuture = super.sendMessage(netconfMessage);
- if (netconfMessage instanceof NetconfNotification) {
+ if (netconfMessage instanceof NetconfNotification notification) {
outNotification++;
- sessionListener.onNotification(this, (NetconfNotification) netconfMessage);
+ sessionListener.onNotification(this, notification);
}
// delayed close was set, close after the message was sent
if (delayedClose) {
.build();
}
- private static Class<? extends Transport> getTransportForString(final String transport) {
- switch (transport) {
- case "ssh":
- return NetconfSsh.class;
- case "tcp":
- return NetconfTcp.class;
- default:
- throw new IllegalArgumentException("Unknown transport type " + transport);
- }
+ private static Transport getTransportForString(final String transport) {
+ return switch (transport) {
+ case "ssh" -> NetconfSsh.VALUE;
+ case "tcp" -> NetconfTcp.VALUE;
+ default -> throw new IllegalArgumentException("Unknown transport type " + transport);
+ };
}
@Override