Java 17 features (N-S) (#15565)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -102,13 +102,13 @@ public class MessageReader extends Thread {
|
||||
pduString = "00" + pduString;
|
||||
}
|
||||
Pdu pdu = parser.parsePdu(pduString);
|
||||
if (pdu instanceof SmsDeliveryPdu) {
|
||||
if (pdu instanceof SmsDeliveryPdu deliveryPdu) {
|
||||
logger.debug("PDU = {}", pdu.toString());
|
||||
InboundMessage msg = null;
|
||||
if (pdu.isBinary()) {
|
||||
msg = new InboundBinaryMessage((SmsDeliveryPdu) pdu, memLocation, memIndex);
|
||||
msg = new InboundBinaryMessage(deliveryPdu, memLocation, memIndex);
|
||||
} else {
|
||||
msg = new InboundMessage((SmsDeliveryPdu) pdu, memLocation, memIndex);
|
||||
msg = new InboundMessage(deliveryPdu, memLocation, memIndex);
|
||||
}
|
||||
msg.setGatewayId(this.modem.getGatewayId());
|
||||
msg.setGatewayId(this.modem.getGatewayId());
|
||||
@@ -153,9 +153,9 @@ public class MessageReader extends Thread {
|
||||
mpMsgList.add(tmpList);
|
||||
}
|
||||
}
|
||||
} else if (pdu instanceof SmsStatusReportPdu) {
|
||||
} else if (pdu instanceof SmsStatusReportPdu statusReportPdu) {
|
||||
DeliveryReportMessage msg;
|
||||
msg = new DeliveryReportMessage((SmsStatusReportPdu) pdu, memLocation, memIndex);
|
||||
msg = new DeliveryReportMessage(statusReportPdu, memLocation, memIndex);
|
||||
msg.setGatewayId(this.modem.getGatewayId());
|
||||
messageList.add(msg);
|
||||
}
|
||||
@@ -376,8 +376,8 @@ public class MessageReader extends Thread {
|
||||
String messageSignature = message.getSignature();
|
||||
if (!this.modem.getReadMessagesSet().contains(messageSignature)) {
|
||||
this.modem.getDeviceInformation().increaseTotalReceived();
|
||||
if (message instanceof DeliveryReportMessage) {
|
||||
modem.processDeliveryReport((DeliveryReportMessage) message);
|
||||
if (message instanceof DeliveryReportMessage deliveryReportMessage) {
|
||||
modem.processDeliveryReport(deliveryReportMessage);
|
||||
} else {
|
||||
modem.processMessage(message);
|
||||
}
|
||||
|
||||
@@ -194,30 +194,30 @@ public abstract class AbstractMessage implements Serializable {
|
||||
b.append(String.format("Recipient Address: %s%n", getRecipientAddress()));
|
||||
b.append(String.format("Payload Type: %s%n", payload.getType()));
|
||||
b.append(String.format("Text payload: %s%n", payload.getText() == null ? "null" : payload.getText()));
|
||||
if (this instanceof InboundMessage) {
|
||||
if (this instanceof InboundMessage message) {
|
||||
b.append(String.format("Sent Date: %s%n", getSentDate()));
|
||||
b.append(String.format("Memory Storage Location: %s%n", ((InboundMessage) this).getMemLocation()));
|
||||
b.append(String.format("Memory Index: %d%n", ((InboundMessage) this).getMemIndex()));
|
||||
b.append(String.format("Memory MP Index: %s%n", ((InboundMessage) this).getMpMemIndex()));
|
||||
b.append(String.format("Memory Storage Location: %s%n", message.getMemLocation()));
|
||||
b.append(String.format("Memory Index: %d%n", message.getMemIndex()));
|
||||
b.append(String.format("Memory MP Index: %s%n", message.getMpMemIndex()));
|
||||
}
|
||||
if (this instanceof OutboundMessage) {
|
||||
if (this instanceof OutboundMessage message) {
|
||||
b.append(String.format("Sent Date: %s%n",
|
||||
(((OutboundMessage) this).getSentStatus() == SentStatus.Sent ? getSentDate() : "N/A")));
|
||||
(message.getSentStatus() == SentStatus.Sent ? getSentDate() : "N/A")));
|
||||
String ids = "";
|
||||
for (String opId : ((OutboundMessage) this).getOperatorMessageIds()) {
|
||||
for (String opId : message.getOperatorMessageIds()) {
|
||||
ids += (ids.length() == 0 ? opId : "," + opId);
|
||||
}
|
||||
b.append(String.format("Operator Message IDs: %s%n", ids));
|
||||
b.append(String.format("Status: %s%n", ((OutboundMessage) this).getSentStatus().toString()));
|
||||
b.append(String.format("Failure: %s%n", ((OutboundMessage) this).getFailureCause().toString()));
|
||||
b.append(String.format("Status: %s%n", message.getSentStatus().toString()));
|
||||
b.append(String.format("Failure: %s%n", message.getFailureCause().toString()));
|
||||
b.append(String.format("Request Delivery Reports: %b%n",
|
||||
((OutboundMessage) this).getRequestDeliveryReport()));
|
||||
message.getRequestDeliveryReport()));
|
||||
}
|
||||
if (this instanceof DeliveryReportMessage) {
|
||||
if (this instanceof DeliveryReportMessage message) {
|
||||
b.append(String.format("Original Operator Message Id: %s%n",
|
||||
((DeliveryReportMessage) this).getOriginalOperatorMessageId()));
|
||||
b.append(String.format("Delivery Date: %s%n", ((DeliveryReportMessage) this).getOriginalReceivedDate()));
|
||||
b.append(String.format("Delivery Status: %s%n", ((DeliveryReportMessage) this).getDeliveryStatus()));
|
||||
message.getOriginalOperatorMessageId()));
|
||||
b.append(String.format("Delivery Date: %s%n", message.getOriginalReceivedDate()));
|
||||
b.append(String.format("Delivery Status: %s%n", message.getDeliveryStatus()));
|
||||
}
|
||||
b.append(String
|
||||
.format("== MESSAGE END ========================================================================%n"));
|
||||
|
||||
Reference in New Issue
Block a user