From eb4482f51e439271f92fd6c8b9bac46fee6f26e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ru=CC=88hl?= Date: Fri, 2 Feb 2018 14:19:17 +0100 Subject: [PATCH] get rid of Optional as field --- .../apache/plc4x/java/ads/connection/ADSPlcConnection.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java index 82be0de51e3..40d7a0a1a1c 100644 --- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java +++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java @@ -36,7 +36,6 @@ Licensed to the Apache Software Foundation (ASF) under one import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,7 +46,7 @@ public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader private final String hostName; - private final Optional suppliedPort; + private final Integer suppliedPort; private final AMSNetId targetAmsNetId; @@ -75,7 +74,7 @@ public ADSPlcConnection(String hostName, AMSNetId targetAmsNetId, AMSPort target public ADSPlcConnection(String hostName, Integer port, AMSNetId targetAmsNetId, AMSPort targetAmsPort, AMSNetId sourceAmsNetId, AMSPort sourceAmsPort) { this.hostName = hostName; - this.suppliedPort = Optional.ofNullable(port); + this.suppliedPort = port; this.targetAmsNetId = targetAmsNetId; this.targetAmsPort = targetAmsPort; this.sourceAmsNetId = sourceAmsNetId; @@ -123,7 +122,7 @@ protected void initChannel(Channel channel) throws Exception { } }); // Start the client. - ChannelFuture f = bootstrap.connect(serverInetAddress, suppliedPort.orElse(TCP_PORT)).sync(); + ChannelFuture f = bootstrap.connect(serverInetAddress, suppliedPort != null ? suppliedPort : TCP_PORT).sync(); f.awaitUninterruptibly(); // Wait till the session is finished initializing. channel = f.channel();