Java 17 features (A-G) (#15516)

- 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:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -53,9 +53,7 @@ public class BoseSoundTouchHandlerFactory extends BaseThingHandlerFactory {
ContentItem.class.getClassLoader());
BoseStateDescriptionOptionProvider localDescriptionOptionProvider = stateOptionProvider;
if (localDescriptionOptionProvider != null) {
BoseSoundTouchHandler handler = new BoseSoundTouchHandler(thing, new PresetContainer(storage),
localDescriptionOptionProvider);
return handler;
return new BoseSoundTouchHandler(thing, new PresetContainer(storage), localDescriptionOptionProvider);
}
}
return null;

View File

@@ -79,8 +79,7 @@ public class ContentItem {
*/
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof ContentItem) {
ContentItem other = (ContentItem) obj;
if (obj instanceof ContentItem other) {
return Objects.equals(other.source, this.source) || Objects.equals(other.sourceAccount, this.sourceAccount)
|| other.presetable == this.presetable || Objects.equals(other.location, this.location)
|| Objects.equals(other.itemName, this.itemName);
@@ -188,11 +187,11 @@ public class ContentItem {
* ' - &apos;
*/
private String escapeXml(String xml) {
xml = xml.replaceAll("&", "&amp;");
xml = xml.replaceAll("<", "&lt;");
xml = xml.replaceAll(">", "&gt;");
xml = xml.replaceAll("\"", "&quot;");
xml = xml.replaceAll("'", "&apos;");
xml = xml.replace("&", "&amp;");
xml = xml.replace("<", "&lt;");
xml = xml.replace(">", "&gt;");
xml = xml.replace("\"", "&quot;");
xml = xml.replace("'", "&apos;");
return xml;
}
@@ -251,7 +250,7 @@ public class ContentItem {
}
public StateOption toStateOption() {
String stateOptionLabel = String.valueOf(presetID) + ": " + itemName;
String stateOptionLabel = presetID + ": " + itemName;
return new StateOption(String.valueOf(presetID), stateOptionLabel);
}