Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade SAT plugin to 0.16.0 #16582

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

Expand All @@ -38,14 +39,14 @@ public abstract class GattSocket<T extends GattMessage, R extends GattMessage> {

private final Deque<MessageProcessor> messageProcessors = new ConcurrentLinkedDeque<>();

public void registerMessageHandler(MessageHandler<T, R> messageHandler) {
public void registerMessageHandler(MessageHandler<@NonNull T, @NonNull R> messageHandler) {
// we need to use a dummy future since ConcurrentHashMap doesn't allow null values
messageProcessors.addFirst(new MessageProcessor(messageHandler, COMPLETED_FUTURE));
}

protected abstract ScheduledExecutorService getScheduler();

public void sendMessage(MessageServicer<T, R> messageServicer) {
public void sendMessage(MessageServicer<@NonNull T, @NonNull R> messageServicer) {
T message = messageServicer.createMessage();

CompletableFuture<@Nullable Void> messageFuture = sendMessage(message);
Expand Down Expand Up @@ -106,10 +107,10 @@ private void handleMessage(R message) {
}

private class MessageProcessor {
private MessageHandler<T, R> messageHandler;
private MessageHandler<@NonNull T, @NonNull R> messageHandler;
private Future<?> timeoutFuture;

public MessageProcessor(MessageHandler<T, R> messageHandler, Future<?> timeoutFuture) {
public MessageProcessor(MessageHandler<@NonNull T, @NonNull R> messageHandler, Future<?> timeoutFuture) {
this.messageHandler = messageHandler;
this.timeoutFuture = timeoutFuture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static void main(String[] args) throws Exception {
// write actual rows
rows.forEach(row -> {
writer.append(writeRow(maxColumns, row, ' ')).append('\n');
if (row == headerRow) {
if (headerRow.equals(row)) {
writer.append(writeRow(maxColumns, new String[] { "", "", "" }, '-')).append('\n');
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.List;
import java.util.Map;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.freeboxos.internal.api.FreeboxException;
Expand Down Expand Up @@ -167,7 +168,8 @@ public HomeNode getHomeNode(int nodeId) throws FreeboxException {
}

public <T> boolean putCommand(int nodeId, int stateSignalId, T value) throws FreeboxException {
put(new EndpointValue<>(value), ENDPOINTS_PATH, String.valueOf(nodeId), String.valueOf(stateSignalId));
put(new EndpointValue<@NonNull T>(value), ENDPOINTS_PATH, String.valueOf(nodeId),
String.valueOf(stateSignalId));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public void onFailure(@Nullable Session session, @Nullable Throwable failure) {
@Override
public void onGoAway(@Nullable Session session, @Nullable GoAwayFrame frame) {
Objects.requireNonNull(session);
if (http2Session == session) {
if (session.equals(http2Session)) {
Thread recreateThread = new Thread(() -> recreateSession());
Clip2Bridge.this.recreateThread = recreateThread;
recreateThread.start();
Expand All @@ -412,7 +412,7 @@ public boolean onIdleTimeout(@Nullable Session session) {
public void onPing(@Nullable Session session, @Nullable PingFrame frame) {
Objects.requireNonNull(session);
Objects.requireNonNull(frame);
if (http2Session == session) {
if (session.equals(http2Session)) {
checkAliveOk();
if (!frame.isReply()) {
session.ping(new PingFrame(true), Callback.NOOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ public void ignoresInvalidEnum() throws Exception {
"homie/device123", fieldChangedObserverMock, 10);
assertThat(future.isDone(), is(true));

SubscribeFieldToMQTTtopic field = attributes.subscriptions.stream().filter(f -> f.field.getName() == "state")
.findFirst().get();
SubscribeFieldToMQTTtopic field = attributes.subscriptions.stream()
.filter(f -> "state".equals(f.field.getName())).findFirst().get();
field.processMessage(field.topic, "garbage".getBytes());
verify(fieldChangedObserverMock, times(0)).attributeChanged(any(), any(), any(), any(), anyBoolean());
assertThat(attributes.state.toString(), is("unknown"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Iterator;
import java.util.List;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.omnilink.internal.exceptions.BridgeOfflineException;
import org.openhab.binding.omnilink.internal.handler.OmnilinkBridgeHandler;
Expand All @@ -42,14 +43,14 @@ public static <T extends ObjectProperties, U extends ObjectPropertyRequests<T>>
}

private final OmnilinkBridgeHandler bridgeHandler;
private final ObjectPropertyRequests<T> request;
private final ObjectPropertyRequests<@NonNull T> request;
private final int objectNumber;
private final int filter1;
private final int filter2;
private final int filter3;
private final int offset;

private ObjectPropertyRequest(OmnilinkBridgeHandler bridgeHandler, ObjectPropertyRequests<T> request,
private ObjectPropertyRequest(OmnilinkBridgeHandler bridgeHandler, ObjectPropertyRequests<@NonNull T> request,
int objectNumber, int filter1, int filter2, int filter3, int offset) {
this.bridgeHandler = bridgeHandler;
this.request = request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void addListener(String channelId, RioHandlerCallbackListener listener) {
@Override
public void removeListener(String channelId, RioHandlerCallbackListener listener) {
for (ListenerState listenerState : listeners) {
if (listenerState.channelId.equals(channelId) && listenerState.listener == listener) {
if (listenerState.channelId.equals(channelId) && listener.equals(listenerState.listener)) {
listeners.remove(listenerState);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void sendKeys(List<KeyCode> keys, int sleepInMs) throws RemoteControllerE

@Override
public boolean isConnected() {
return socket != null && !socket.isClosed() && socket != null && socket.isConnected();
return socket != null && !socket.isClosed() && socket.isConnected();
}

private String createRegistrationPayload(String ip) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand All @@ -41,9 +42,9 @@ public class SpotifyDynamicStateDescriptionProvider extends BaseDynamicStateDesc
public void setDevices(ChannelUID channelUID, List<Device> spotifyDevices) {
final List<Device> devices = devicesByChannel.get(channelUID);

if (devices == null || (spotifyDevices.size() != devices.size()
|| !spotifyDevices.stream().allMatch(sd -> devices.stream().anyMatch(
d -> sd.getId() == d.getId() && d.getName() != null && d.getName().equals(sd.getName()))))) {
if (devices == null || (spotifyDevices.size() != devices.size() || !spotifyDevices.stream()
.allMatch(sd -> devices.stream().anyMatch(d -> Objects.equals(sd.getId(), d.getId())
&& d.getName() != null && d.getName().equals(sd.getName()))))) {
devicesByChannel.put(channelUID, spotifyDevices);
setStateOptions(channelUID, spotifyDevices.stream()
.map(device -> new StateOption(device.getId(), device.getName())).collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.verisure.internal.DeviceStatusListener;
Expand Down Expand Up @@ -51,7 +52,7 @@
*
*/
@NonNullByDefault
public abstract class VerisureThingHandler<T extends VerisureThingDTO> extends BaseThingHandler
public abstract class VerisureThingHandler<@NonNull T extends VerisureThingDTO> extends BaseThingHandler
implements DeviceStatusListener<T> {

protected final Logger logger = LoggerFactory.getLogger(VerisureThingHandler.class);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<okio.version>3.9.0</okio.version>
<gson.version>2.9.1</gson.version>
<kotlin.version>1.9.23</kotlin.version>
<sat.version>0.15.0</sat.version>
<sat.version>0.16.0</sat.version>
<slf4j.version>2.0.7</slf4j.version>
<spotless.version>2.38.0</spotless.version>
<!-- Eclipse Java formatter version 4.26+ does not check test files -->
Expand Down