Skip to content

Commit

Permalink
Adressing code review n°1
Browse files Browse the repository at this point in the history
Signed-off-by: root <gael@lhopital.org>
  • Loading branch information
clinique committed Apr 28, 2024
1 parent 6fe3c32 commit 995841a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.netatmo.internal.api.dto;

import java.util.Objects;
import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand Down Expand Up @@ -96,8 +95,8 @@ public SirenStatus getSirenStatus() {
return sirenStatus;
}

public String getVpnUrl() {
return Objects.requireNonNull(vpnUrl);
public @Nullable String getVpnUrl() {
return vpnUrl;
}

public boolean isLocal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void updateHomeStatusModule(HomeStatusModule newData) {
super.updateHomeStatusModule(newData);
// Per documentation vpn_url expires every 3 hours and on camera reboot. So useless to reping it if not changed
String newVpnUrl = newData.getVpnUrl();
if (!newVpnUrl.equals(vpnUrl)) {
if (newVpnUrl != null && !newVpnUrl.equals(vpnUrl)) {
// This will also decrease the number of requests emitted toward Netatmo API.
localUrl = newData.isLocal() ? ping(newVpnUrl) : null;
logger.debug("localUrl set to {} for camera {}", localUrl, thingUID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public CameraChannelHelper(Set<String> providedGroups) {
}

public void setUrls(String vpnUrl, @Nullable String localUrl) {
this.vpnUrl = vpnUrl;
this.localUrl = localUrl;
this.vpnUrl = vpnUrl;
}

@Override
Expand All @@ -65,7 +65,7 @@ public void setUrls(String vpnUrl, @Nullable String localUrl) {
}

public @Nullable String getLivePictureURL(boolean local, boolean isMonitoring) {
if (!isMonitoring || (local && (localUrl != null))) {
if (!isMonitoring || (local && (localUrl == null))) {
return null;
}
return "%s%s".formatted(getUrl(local), LIVE_PICTURE);
Expand Down Expand Up @@ -94,8 +94,8 @@ public void setUrls(String vpnUrl, @Nullable String localUrl) {
};
}

private String getUrl(boolean local) {
return Objects.requireNonNull(local ? localUrl : vpnUrl);
private @Nullable String getUrl(boolean local) {
return local ? localUrl : vpnUrl;
}

private State getLiveStreamURL(boolean local, @Nullable String configQual, boolean isMonitoring) {
Expand Down

0 comments on commit 995841a

Please sign in to comment.