mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-17 13:11:00 +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 Manager m,
|
||||||
final OutputWriter outputWriter
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var callIdNumber = ns.get("call-id");
|
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||||
if (callIdNumber == null) {
|
|
||||||
throw new UserErrorException("No call ID given");
|
throw new UserErrorException("No call ID given");
|
||||||
}
|
}
|
||||||
final long callId = ((Number) callIdNumber).longValue();
|
final long callId = callIdNumber.longValue();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var callInfo = m.acceptCall(callId);
|
var callInfo = m.acceptCall(callId);
|
||||||
|
|||||||
@ -33,11 +33,10 @@ public class HangupCallCommand implements JsonRpcLocalCommand {
|
|||||||
final Manager m,
|
final Manager m,
|
||||||
final OutputWriter outputWriter
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var callIdNumber = ns.get("call-id");
|
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||||
if (callIdNumber == null) {
|
|
||||||
throw new UserErrorException("No call ID given");
|
throw new UserErrorException("No call ID given");
|
||||||
}
|
}
|
||||||
final long callId = ((Number) callIdNumber).longValue();
|
final long callId = callIdNumber.longValue();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.hangupCall(callId);
|
m.hangupCall(callId);
|
||||||
|
|||||||
@ -33,11 +33,10 @@ public class RejectCallCommand implements JsonRpcLocalCommand {
|
|||||||
final Manager m,
|
final Manager m,
|
||||||
final OutputWriter outputWriter
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var callIdNumber = ns.get("call-id");
|
if (!(ns.get("call-id") instanceof Number callIdNumber)) {
|
||||||
if (callIdNumber == null) {
|
|
||||||
throw new UserErrorException("No call ID given");
|
throw new UserErrorException("No call ID given");
|
||||||
}
|
}
|
||||||
final long callId = ((Number) callIdNumber).longValue();
|
final long callId = callIdNumber.longValue();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.rejectCall(callId);
|
m.rejectCall(callId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user