@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) {
* @return Two values - port and host of socket address
*/
protected static Map.Entry<String, String> getHostName(final SocketAddress socketAddress) {
- if (socketAddress instanceof InetSocketAddress) {
- final var inetSocketAddress = (InetSocketAddress) socketAddress;
+ if (socketAddress instanceof InetSocketAddress inetSocketAddress) {
return new SimpleImmutableEntry<>(Integer.toString(inetSocketAddress.getPort()),
inetSocketAddress.getHostString());
- } else if (socketAddress instanceof LocalAddress) {
- return new SimpleImmutableEntry<>(UNKNOWN, ((LocalAddress) socketAddress).id());
+ } else if (socketAddress instanceof LocalAddress localAddress) {
+ return new SimpleImmutableEntry<>(UNKNOWN, localAddress.id());
} else {
return new SimpleImmutableEntry<>(UNKNOWN, UNKNOWN);
}
for (final NetconfOperation netconfOperation : allNetconfOperations) {
final HandlingPriority handlingPriority = netconfOperation.canHandle(message);
- if (netconfOperation instanceof DefaultNetconfOperation) {
- ((DefaultNetconfOperation) netconfOperation).setNetconfSession(session);
+ if (netconfOperation instanceof DefaultNetconfOperation defaultOperation) {
+ defaultOperation.setNetconfSession(session);
}
- if (netconfOperation instanceof SessionAwareNetconfOperation) {
- ((SessionAwareNetconfOperation) netconfOperation).setSession(session);
+ if (netconfOperation instanceof SessionAwareNetconfOperation sessionAwareOperation) {
+ sessionAwareOperation.setSession(session);
}
if (!handlingPriority.equals(HandlingPriority.CANNOT_HANDLE)) {