mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-13 12:30:20 +00:00
Use instanceof pattern matching for call ID extraction
Replace explicit null check and Number cast with instanceof pattern matching in AcceptCallCommand, HangupCallCommand, and RejectCallCommand. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ad8d692a13
commit
cb7725482a
@ -35,11 +35,10 @@ public class AcceptCallCommand implements JsonRpcLocalCommand {
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var callIdNumber = ns.get("call-id");
|
||||
if (callIdNumber == null) {
|
||||
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||
throw new UserErrorException("No call ID given");
|
||||
}
|
||||
final long callId = ((Number) callIdNumber).longValue();
|
||||
final long callId = callIdNumber.longValue();
|
||||
|
||||
try {
|
||||
var callInfo = m.acceptCall(callId);
|
||||
|
||||
@ -33,11 +33,10 @@ public class HangupCallCommand implements JsonRpcLocalCommand {
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var callIdNumber = ns.get("call-id");
|
||||
if (callIdNumber == null) {
|
||||
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||
throw new UserErrorException("No call ID given");
|
||||
}
|
||||
final long callId = ((Number) callIdNumber).longValue();
|
||||
final long callId = callIdNumber.longValue();
|
||||
|
||||
try {
|
||||
m.hangupCall(callId);
|
||||
|
||||
@ -33,11 +33,10 @@ public class RejectCallCommand implements JsonRpcLocalCommand {
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var callIdNumber = ns.get("call-id");
|
||||
if (callIdNumber == null) {
|
||||
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||
throw new UserErrorException("No call ID given");
|
||||
}
|
||||
final long callId = ((Number) callIdNumber).longValue();
|
||||
final long callId = callIdNumber.longValue();
|
||||
|
||||
try {
|
||||
m.rejectCall(callId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user