Skip to content

Commit

Permalink
get rid of Optional as field
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Feb 2, 2018
1 parent b1824a5 commit eb4482f
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,7 +46,7 @@ public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader

private final String hostName;

private final Optional<Integer> suppliedPort;
private final Integer suppliedPort;

private final AMSNetId targetAmsNetId;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit eb4482f

Please sign in to comment.