Fix inspection issues

This commit is contained in:
AsamK 2023-12-15 17:32:30 +01:00
parent fc6a4b78eb
commit caa4fa0180
12 changed files with 12 additions and 15 deletions

View file

@ -220,7 +220,7 @@ public class SendHelper {
(messageSender, address, unidentifiedAccess) -> messageSender.sendTyping(List.of(address),
List.of(unidentifiedAccess),
message,
null).get(0));
null).getFirst());
handleSendMessageResult(result);
return result;
}

View file

@ -302,7 +302,7 @@ public class StorageHelper {
logger.warn("Failed to read storage records, ignoring.");
return null;
}
return !records.isEmpty() ? records.get(0) : null;
return !records.isEmpty() ? records.getFirst() : null;
}
private List<SignalStorageRecord> getSignalStorageRecords(final Collection<StorageId> storageIds) throws IOException {

View file

@ -1291,7 +1291,7 @@ public class ManagerImpl implements Manager {
r -> context.getIdentityHelper().trustIdentityVerifiedSafetyNumber(r, safetyNumber.safetyNumber()));
case IdentityVerificationCode.ScannableSafetyNumber safetyNumber -> trustIdentity(recipient,
r -> context.getIdentityHelper().trustIdentityVerifiedSafetyNumber(r, safetyNumber.safetyNumber()));
case null, default -> throw new AssertionError("Invalid verification code type");
case null -> throw new AssertionError("Invalid verification code type");
};
}

View file

@ -94,7 +94,7 @@ public class DbusCommandHandler {
"Multiple users found, you need to specify an account (phone number) with -a");
}
return accounts.get(0).getPath();
return accounts.getFirst().getPath();
} catch (UnknownMethod e) {
// dbus daemon not running in multi-account mode
return null;

View file

@ -52,7 +52,6 @@ public abstract class DbusProperties implements Properties {
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Variant<?>> GetAll(final String interface_name) {
final var handler = getHandlerOptional(interface_name);
if (handler.isEmpty()) {

View file

@ -668,7 +668,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
@Override
public boolean isRegistered(String number) {
var result = isRegistered(List.of(number));
return result.get(0);
return result.getFirst();
}
@Override

View file

@ -2,8 +2,6 @@ package org.asamk.signal.jsonrpc;
/**
* Represents a JSON-RPC (batch) request or (batch) response.
* https://www.jsonrpc.org/specification
* <a href="https://www.jsonrpc.org/specification">https://www.jsonrpc.org/specification</a>
*/
public sealed abstract class JsonRpcMessage permits JsonRpcBatchMessage, JsonRpcRequest, JsonRpcResponse {
}
public sealed abstract class JsonRpcMessage permits JsonRpcBatchMessage, JsonRpcRequest, JsonRpcResponse {}

View file

@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.node.ValueNode;
/**
* Represents a JSON-RPC request.
* https://www.jsonrpc.org/specification#request_object
* <a href="https://www.jsonrpc.org/specification#request_object">https://www.jsonrpc.org/specification#request_object</a>
*/
public final class JsonRpcRequest extends JsonRpcMessage {

View file

@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.node.ValueNode;
/**
* Represents a JSON-RPC response.
* https://www.jsonrpc.org/specification#response_object
* <a href="https://www.jsonrpc.org/specification#response_object">https://www.jsonrpc.org/specification#response_object</a>
*/
public final class JsonRpcResponse extends JsonRpcMessage {

View file

@ -94,7 +94,7 @@ public class SignalJsonRpcCommandHandler {
if (manager == null) {
final var managers = c.getManagers();
if (managers.size() == 1) {
manager = managers.get(0);
manager = managers.getFirst();
}
}
if (manager != null) {

View file

@ -126,7 +126,7 @@ public class SignalJsonRpcDispatcherHandler {
private void unsubscribeReceive(final Manager m) {
final var subscriptionId = receiveHandlers.entrySet()
.stream()
.filter(e -> e.getValue().size() == 1 && e.getValue().get(0).first().equals(m))
.filter(e -> e.getValue().size() == 1 && e.getValue().getFirst().first().equals(m))
.map(Map.Entry::getKey)
.findFirst();
subscriptionId.ifPresent(this::unsubscribeReceive);

View file

@ -42,7 +42,7 @@ public class Util {
if (strings.isEmpty()) {
return "";
}
return strings.get(0) + strings.stream()
return strings.getFirst() + strings.stream()
.skip(1)
.filter(s -> !s.isEmpty())
.map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase(Locale.ROOT))