Java 17 features (H-M) (#15520)
- 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 - remove null check before instanceof Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -168,8 +168,8 @@ public class PatchedMailcapCommandMap extends CommandMap {
|
||||
if (fieldName.startsWith("x-java-") && fieldName.length() > 7) {
|
||||
String command = fieldName.substring(7);
|
||||
value = value.trim();
|
||||
if (command.equals("fallback-entry")) {
|
||||
if (value.equals("true")) {
|
||||
if ("fallback-entry".equals(command)) {
|
||||
if ("true".equals(value)) {
|
||||
fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ public class POP3IMAPHandler extends BaseThingHandler {
|
||||
}
|
||||
Object rawContent = message.getContent();
|
||||
String contentAsString;
|
||||
if (rawContent instanceof String) {
|
||||
if (rawContent instanceof String str) {
|
||||
logger.trace("Detected plain text message");
|
||||
contentAsString = (String) rawContent;
|
||||
contentAsString = str;
|
||||
} else if (rawContent instanceof MimeMessage mimeMessage) {
|
||||
logger.trace("Detected MIME message");
|
||||
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
|
||||
|
||||
@@ -115,8 +115,7 @@ public class SMTPHandler extends BaseThingHandler {
|
||||
Field dataField = dataSource.getClass().getDeclaredField("data");
|
||||
dataField.setAccessible(true);
|
||||
Object data = dataField.get(dataSource);
|
||||
if (data instanceof MimeMultipart) {
|
||||
MimeMultipart mimeMultipart = (MimeMultipart) data;
|
||||
if (data instanceof MimeMultipart mimeMultipart) {
|
||||
for (int i = 0; i < mimeMultipart.getCount(); i++) {
|
||||
Part mimePart = mimeMultipart.getBodyPart(i);
|
||||
mimePart.getDataHandler().setCommandMap(commandMap);
|
||||
|
||||
@@ -230,8 +230,8 @@ public class SendMailActions implements ThingActions {
|
||||
|
||||
@Override
|
||||
public void setThingHandler(@Nullable ThingHandler handler) {
|
||||
if (handler instanceof SMTPHandler) {
|
||||
this.handler = (SMTPHandler) handler;
|
||||
if (handler instanceof SMTPHandler smtpHandler) {
|
||||
this.handler = smtpHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user