Use Optional.ofNullable()
@@ -63,11 +63,12 @@ public class DHCPPool implements IDHCPPool {
public Optional<IPv4Address> getLeaseIP(@Nonnull MacAddress clientMac) {
DHCPBinding binding = dhcpLeasingPool.get(clientMac);
return binding != null ? Optional.of(binding.getIPv4Address()) : Optional.empty();
+
}
public Optional<DHCPBinding> getLeaseBinding(@Nonnull MacAddress clientMac) {
DHCPBinding binding = dhcpLeasingPool.get(clientMac);
- return binding != null ? Optional.of(binding) : Optional.empty();
+ return Optional.ofNullable(binding);
}
public boolean isPoolAvailable() { return !dhcpRepository.isEmpty(); }
