Cleanup: Java21, SAT (#4757)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>pull/4763/head
parent
8fbea76834
commit
7820dc45bd
|
@ -165,7 +165,7 @@ public class CommunityKarafAddonHandler implements MarketplaceAddonHandler {
|
|||
"The local cache folder doesn't contain a single file: " + addonPath, null);
|
||||
}
|
||||
try {
|
||||
karService.install(karFiles.get(0).toUri(), false);
|
||||
karService.install(karFiles.getFirst().toUri(), false);
|
||||
} catch (Exception e) {
|
||||
throw new MarketplaceHandlerException(
|
||||
"Cannot install KAR from marketplace cache: " + e.getMessage(), e);
|
||||
|
|
|
@ -32,17 +32,17 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
|||
public abstract class AbstractJacksonYAMLParser<T> implements Parser<T> {
|
||||
|
||||
/** The YAML object mapper instance */
|
||||
protected static final ObjectMapper yamlMapper;
|
||||
protected static final ObjectMapper YAML_MAPPER;
|
||||
|
||||
static {
|
||||
yamlMapper = new ObjectMapper(new YAMLFactory());
|
||||
yamlMapper.findAndRegisterModules();
|
||||
YAML_MAPPER = new ObjectMapper(new YAMLFactory());
|
||||
YAML_MAPPER.findAndRegisterModules();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Set<T> dataObjects, OutputStreamWriter writer) throws Exception {
|
||||
for (T dataObject : dataObjects) {
|
||||
yamlMapper.writeValue(writer, dataObject);
|
||||
YAML_MAPPER.writeValue(writer, dataObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,16 +43,16 @@ public class TemplateYAMLParser extends AbstractJacksonYAMLParser<Template> {
|
|||
public Set<Template> parse(InputStreamReader reader) throws ParsingException {
|
||||
try {
|
||||
Set<Template> templates = new HashSet<>();
|
||||
JsonNode rootNode = yamlMapper.readTree(reader);
|
||||
JsonNode rootNode = YAML_MAPPER.readTree(reader);
|
||||
if (rootNode.isArray()) {
|
||||
List<RuleTemplateDTO> templateDtos = yamlMapper.convertValue(rootNode,
|
||||
List<RuleTemplateDTO> templateDtos = YAML_MAPPER.convertValue(rootNode,
|
||||
new TypeReference<List<RuleTemplateDTO>>() {
|
||||
});
|
||||
for (RuleTemplateDTO templateDTO : templateDtos) {
|
||||
templates.add(RuleTemplateDTOMapper.map(templateDTO));
|
||||
}
|
||||
} else {
|
||||
RuleTemplateDTO templateDto = yamlMapper.convertValue(rootNode, new TypeReference<RuleTemplateDTO>() {
|
||||
RuleTemplateDTO templateDto = YAML_MAPPER.convertValue(rootNode, new TypeReference<RuleTemplateDTO>() {
|
||||
});
|
||||
templates.add(RuleTemplateDTOMapper.map(templateDto));
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
*/
|
||||
package org.openhab.core.automation.parser;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
|
@ -23,6 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||
@NonNullByDefault
|
||||
public class ValidationException extends Exception {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.Path;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
|
@ -223,7 +223,7 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
|||
}
|
||||
|
||||
private URL getUrl(String filename) throws FileNotFoundException {
|
||||
if (Files.exists(Paths.get(filename))) {
|
||||
if (Files.exists(Path.of(filename))) {
|
||||
try {
|
||||
return (new URI("file:" + filename)).toURL();
|
||||
} catch (IllegalArgumentException | MalformedURLException | URISyntaxException e) {
|
||||
|
|
|
@ -198,7 +198,7 @@ public class LogWebSocket implements LogListener {
|
|||
lastSentTime = System.currentTimeMillis();
|
||||
|
||||
// Remove any duplicates from the live log buffer
|
||||
long newestSequence = logs.get(0).getSequence();
|
||||
long newestSequence = logs.getFirst().getSequence();
|
||||
synchronized (deferredLogs) {
|
||||
Iterator<LogDTO> iterator = deferredLogs.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
|
|
@ -234,7 +234,6 @@ public class ModelRepositoryImpl implements ModelRepository {
|
|||
|
||||
@Override
|
||||
public void generateSyntaxFromModel(OutputStream out, String modelType, EObject modelContent) {
|
||||
String result = "";
|
||||
synchronized (resourceSet) {
|
||||
String name = "tmp_generated_syntax_%d.%s".formatted(++counter, modelType);
|
||||
Resource resource = resourceSet.createResource(URI.createURI(name));
|
||||
|
|
|
@ -722,7 +722,6 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
|||
errors.add("could not create new instance of %s".formatted(elementClass.getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
elt = objectMapper.treeToValue(node, elementClass);
|
||||
|
|
|
@ -108,7 +108,6 @@ public interface QueryablePersistenceService extends PersistenceService {
|
|||
*
|
||||
* @param itemName name of item
|
||||
* @param alias alias of item
|
||||
*
|
||||
* @return a {@link PersistedItem} or null if the item has not been persisted
|
||||
*/
|
||||
default @Nullable PersistedItem persistedItem(String itemName, @Nullable String alias) {
|
||||
|
|
|
@ -313,7 +313,7 @@ public class SemanticsServiceImpl implements SemanticsService, RegistryChangeLis
|
|||
}
|
||||
}
|
||||
} else if (Equipment.class.isAssignableFrom(semanticTag)) {
|
||||
if (parentLocations.size() > 0 && parentEquipments.size() > 0) {
|
||||
if (!parentLocations.isEmpty() && !parentEquipments.isEmpty()) {
|
||||
warnings.add(String.format(
|
||||
"It belongs to location(s) %s and equipment(s) %s. An Equipment can only belong to one Location or another Equipment, but not both.",
|
||||
parentLocations.toString(), parentEquipments.toString()));
|
||||
|
@ -333,7 +333,7 @@ public class SemanticsServiceImpl implements SemanticsService, RegistryChangeLis
|
|||
warnings.add(String.format("It is a %s item, not a group. A location should be a Group Item.",
|
||||
item.getType()));
|
||||
}
|
||||
if (parentEquipments.size() > 0) {
|
||||
if (!parentEquipments.isEmpty()) {
|
||||
warnings.add(String.format(
|
||||
"It belongs to equipment(s) %s. A Location can only belong to another Location, not Equipment.",
|
||||
parentEquipments.toString()));
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
package org.openhab.core.internal.library.unit;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
|
@ -34,6 +35,7 @@ import tech.units.indriya.function.Calculus;
|
|||
*/
|
||||
@NonNullByDefault
|
||||
public class CurrencyConverter extends AbstractConverter {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final BigDecimal factor;
|
||||
|
|
|
@ -242,7 +242,6 @@ public abstract class GenericItem implements ActiveItem {
|
|||
public void setState(State state, @Nullable State lastState, @Nullable ZonedDateTime lastStateUpdate,
|
||||
@Nullable ZonedDateTime lastStateChange) {
|
||||
State oldState = this.state;
|
||||
ZonedDateTime oldStateUpdate = this.lastStateUpdate;
|
||||
this.state = state;
|
||||
this.lastState = lastState != null ? lastState : this.lastState;
|
||||
this.lastStateUpdate = lastStateUpdate != null ? lastStateUpdate : this.lastStateUpdate;
|
||||
|
|
Loading…
Reference in New Issue