Skip to content

Commit

Permalink
Switching to addons.xml, headers updated
Browse files Browse the repository at this point in the history
Signed-off-by: clinique <gael@lhopital.org>
  • Loading branch information
clinique committed Jan 20, 2023
1 parent 1be36d3 commit 3e0be2e
Show file tree
Hide file tree
Showing 32 changed files with 186 additions and 163 deletions.
8 changes: 4 additions & 4 deletions bundles/org.openhab.binding.freeboxos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
<artifactId>org.openhab.binding.freeboxos</artifactId>

<name>openHAB Add-ons :: Bundles :: FreeboxOS Binding</name>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.github.seancfoley</groupId>
<artifactId>ipaddress</artifactId>
<version>5.4.0</version>
<groupId>com.github.seancfoley</groupId>
<artifactId>ipaddress</artifactId>
<version>5.4.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class ActivePlayerActions extends PlayerActions {
@RuleAction(label = "reboot freebox player", description = "Reboots the Freebox Player")
public void reboot() {
logger.debug("Player reboot called");
PlayerHandler playerHandler = this.handler;
if (playerHandler instanceof ActivePlayerHandler activeHandler) {
activeHandler.reboot();
PlayerHandler localHandler = this.handler;
if (localHandler instanceof ActivePlayerHandler) {
((ActivePlayerHandler) localHandler).reboot();
} else {
logger.warn("Freebox Player Action service ThingHandler is null!");
logger.warn("Freebox Player Action service ThingHandler is null");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*/
package org.openhab.binding.freeboxos.internal.action;

import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.freeboxos.internal.handler.CallHandler;
Expand All @@ -33,24 +31,27 @@
@NonNullByDefault
public class CallActions implements ThingActions {
private final Logger logger = LoggerFactory.getLogger(CallActions.class);
private Optional<CallHandler> handler = Optional.empty();
private @Nullable CallHandler handler;

@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof CallHandler callHandler) {
this.handler = Optional.of(callHandler);
if (handler instanceof CallHandler) {
this.handler = (CallHandler) handler;
}
}

@Override
public @Nullable ThingHandler getThingHandler() {
return handler.orElse(null);
return handler;
}

@RuleAction(label = "clear call queue", description = "Delete all call logged in the queue")
public void reset() {
logger.debug("Call log clear called");
handler.ifPresentOrElse(CallHandler::emptyQueue,
() -> logger.warn("Call Action service ThingHandler is null!"));
if (handler != null) {
handler.emptyQueue();
} else {
logger.warn("Call Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void reset() {
if (plugHandler != null) {
plugHandler.reset();
} else {
logger.warn("Freeplug Action service ThingHandler is null!");
logger.warn("Freeplug Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void wol() {
if (hostHandler != null) {
hostHandler.wol();
} else {
logger.warn("LanHost Action service ThingHandler is null!");
logger.warn("LanHost Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void sendKey(@ActionInput(name = "key") String key) {
if (playerHandler != null) {
playerHandler.sendKey(key, false, 1);
} else {
logger.warn("Freebox Player Action service ThingHandler is null!");
logger.warn("Freebox Player Action service ThingHandler is null");
}
}

Expand All @@ -64,7 +64,7 @@ public void sendLongKey(@ActionInput(name = "key") String key) {
if (playerHandler != null) {
playerHandler.sendKey(key, true, 1);
} else {
logger.warn("Freebox Player Action service ThingHandler is null!");
logger.warn("Freebox Player Action service ThingHandler is null");
}
}

Expand All @@ -75,7 +75,7 @@ public void sendMultipleKeys(@ActionInput(name = "keys") String keys) {
if (playerHandler != null) {
playerHandler.sendMultipleKeys(keys);
} else {
logger.warn("Freebox Player Action service ThingHandler is null!");
logger.warn("Freebox Player Action service ThingHandler is null");
}
}

Expand All @@ -86,7 +86,7 @@ public void sendKeyRepeat(@ActionInput(name = "key") String key, @ActionInput(na
if (playerHandler != null) {
playerHandler.sendKey(key, false, count);
} else {
logger.warn("Freebox Player Action service ThingHandler is null!");
logger.warn("Freebox Player Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*/
package org.openhab.binding.freeboxos.internal.action;

import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.freeboxos.internal.handler.RepeaterHandler;
Expand All @@ -33,24 +31,28 @@
@NonNullByDefault
public class RepeaterActions implements ThingActions {
private final Logger logger = LoggerFactory.getLogger(RepeaterActions.class);
private Optional<RepeaterHandler> handler = Optional.empty();
private @Nullable RepeaterHandler handler;

@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof RepeaterHandler repeaterHandler) {
this.handler = Optional.of(repeaterHandler);
if (handler instanceof RepeaterHandler) {
this.handler = (RepeaterHandler) handler;
}
}

@Override
public @Nullable ThingHandler getThingHandler() {
return handler.orElse(null);
return handler;
}

@RuleAction(label = "reboot free repeater", description = "Reboots the Free Repeater")
public void reboot() {
logger.debug("Repeater reboot called");
handler.ifPresentOrElse(RepeaterHandler::reboot,
() -> logger.warn("Repeater Action service ThingHandler is null!"));
RepeaterHandler localHandler = this.handler;
if (localHandler != null) {
localHandler.reboot();
} else {
logger.warn("Repeater Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void reboot() {
if (serverHandler != null) {
serverHandler.reboot();
} else {
logger.warn("Freebox Action service ThingHandler is null!");
logger.warn("Freebox Action service ThingHandler is null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.jetty.http.HttpStatus.Code;
import org.openhab.binding.freeboxos.internal.api.deserialization.ForegroundAppDeserializer;
import org.openhab.binding.freeboxos.internal.api.deserialization.ListDeserializer;
import org.openhab.binding.freeboxos.internal.api.deserialization.OptionalTypeAdapter;
import org.openhab.binding.freeboxos.internal.api.deserialization.StrictEnumTypeAdapterFactory;
import org.openhab.binding.freeboxos.internal.api.rest.PlayerManager.ForegroundApp;
import org.openhab.core.i18n.TimeZoneProvider;
Expand Down Expand Up @@ -88,8 +87,7 @@ public ApiHandler(HttpClient httpClient, TimeZoneProvider timeZoneProvider) {
(JsonDeserializer<IPAddress>) (json, type,
jsonDeserializationContext) -> new IPAddressString(json.getAsString()).getAddress())
.registerTypeAdapter(ForegroundApp.class, new ForegroundAppDeserializer())
.registerTypeAdapter(List.class, new ListDeserializer())
.registerTypeAdapterFactory(OptionalTypeAdapter.FACTORY).serializeNulls()
.registerTypeAdapter(List.class, new ListDeserializer()).serializeNulls()
.registerTypeAdapterFactory(new StrictEnumTypeAdapterFactory()).create();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ private static enum Visibility {
DASHBOARD,
UNKNOWN;
}

}

public static enum Status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ public LanManager(FreeboxOsSession session) throws FreeboxException {
super(session, Permission.NONE, Config.class, session.getUriBuilder().path(PATH), CONFIG_PATH);
session.addManager(LanBrowserManager.class, new LanBrowserManager(session, getUriBuilder()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ public void setBrightness(Callable<Integer> function) throws FreeboxException {
throw new FreeboxException(e, "Error setting brightness");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public Session openSession(String appToken) throws FreeboxException {
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e);
}

}

public void closeSession() throws FreeboxException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ public NetShareManager(FreeboxOsSession session) throws FreeboxException {
session.addManager(SambaManager.class, new SambaManager(session, getUriBuilder()));
session.addManager(AfpManager.class, new AfpManager(session, getUriBuilder()));
}

}
Loading

0 comments on commit 3e0be2e

Please sign in to comment.