mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
Fix various deprecations (#1595)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
545608dab3
commit
d5529f0c1b
@ -347,8 +347,8 @@ public class AudioFormat {
|
||||
|
||||
// If required set BigEndian, BitDepth, BitRate, and Frequency to default values
|
||||
if (null == format.isBigEndian()) {
|
||||
format = new AudioFormat(format.getContainer(), format.getCodec(), new Boolean(true),
|
||||
format.getBitDepth(), format.getBitRate(), format.getFrequency());
|
||||
format = new AudioFormat(format.getContainer(), format.getCodec(), Boolean.TRUE, format.getBitDepth(),
|
||||
format.getBitRate(), format.getFrequency());
|
||||
}
|
||||
if (null == format.getBitDepth() || null == format.getBitRate() || null == format.getFrequency()) {
|
||||
// Define default values
|
||||
@ -363,19 +363,19 @@ public class AudioFormat {
|
||||
// These values must be interdependent (bitRate = bitDepth * frequency)
|
||||
if (null == bitRate) {
|
||||
if (null == bitDepth) {
|
||||
bitDepth = new Integer(defaultBitDepth);
|
||||
bitDepth = Integer.valueOf(defaultBitDepth);
|
||||
}
|
||||
if (null == frequency) {
|
||||
frequency = new Long(defaultFrequency);
|
||||
frequency = Long.valueOf(defaultFrequency);
|
||||
}
|
||||
bitRate = new Integer(bitDepth.intValue() * frequency.intValue());
|
||||
bitRate = Integer.valueOf(bitDepth.intValue() * frequency.intValue());
|
||||
} else if (null == bitDepth) {
|
||||
if (null == frequency) {
|
||||
frequency = new Long(defaultFrequency);
|
||||
frequency = Long.valueOf(defaultFrequency);
|
||||
}
|
||||
bitDepth = new Integer(bitRate.intValue() / frequency.intValue());
|
||||
bitDepth = Integer.valueOf(bitRate.intValue() / frequency.intValue());
|
||||
} else if (null == frequency) {
|
||||
frequency = new Long(bitRate.longValue() / bitDepth.longValue());
|
||||
frequency = Long.valueOf(bitRate.longValue() / bitDepth.longValue());
|
||||
}
|
||||
|
||||
format = new AudioFormat(format.getContainer(), format.getCodec(), format.isBigEndian(), bitDepth,
|
||||
|
@ -31,9 +31,9 @@ public class AudioFormatTest {
|
||||
private final String testContainer = AudioFormat.CONTAINER_WAVE;
|
||||
private final String testCodec = AudioFormat.CODEC_PCM_SIGNED;
|
||||
private final boolean testBigEndian = true;
|
||||
private final Integer testBitDepth = new Integer(16);
|
||||
private final Integer testBitRate = new Integer(1000);
|
||||
private final Long testFrequency = new Long(1024);
|
||||
private final Integer testBitDepth = Integer.valueOf(16);
|
||||
private final Integer testBitRate = Integer.valueOf(1000);
|
||||
private final Long testFrequency = Long.valueOf(1024);
|
||||
|
||||
@Test
|
||||
public void thereIsNoBestMatchForAnAudioFormatIfOneOfTheFieldsIsNull() {
|
||||
|
@ -105,7 +105,7 @@ public class Printer {
|
||||
|
||||
List<String> rulesRows = new ArrayList<>();
|
||||
for (int i = 1; i <= ruleUIDs.size(); i++) {
|
||||
String id = new Integer(i).toString();
|
||||
String id = String.valueOf(i);
|
||||
String uid = ruleUIDs.get(id);
|
||||
columnValues.set(0, id);
|
||||
columnValues.set(1, uid);
|
||||
@ -563,7 +563,7 @@ public class Printer {
|
||||
*/
|
||||
private static void collectListRecords(Map<String, String> list, List<String> rows, int[] columnWidths) {
|
||||
for (int i = 1; i <= list.size(); i++) {
|
||||
String id = new Integer(i).toString();
|
||||
String id = String.valueOf(i);
|
||||
String uid = list.get(id);
|
||||
List<String> columnValues = new ArrayList<>();
|
||||
columnValues.add(id);
|
||||
|
@ -42,7 +42,7 @@ public class Utils {
|
||||
static Map<String, String> putInHastable(String[] strings) {
|
||||
Hashtable<String, String> sorted = new Hashtable<>();
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
sorted.put(new Integer(i + 1).toString(), strings[i]);
|
||||
sorted.put(String.valueOf(i + 1), strings[i]);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class ConfigDispatcherFileWatcherTest {
|
||||
configDispatcherFileWatcher.processWatchEvent(null, StandardWatchEventKinds.ENTRY_CREATE,
|
||||
new File(path).toPath());
|
||||
|
||||
verifyZeroInteractions(configDispatcher);
|
||||
verifyNoInteractions(configDispatcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -74,7 +74,7 @@ public class ConfigDispatcherFileWatcherTest {
|
||||
configDispatcherFileWatcher.processWatchEvent(null, StandardWatchEventKinds.ENTRY_MODIFY,
|
||||
new File(path).toPath());
|
||||
|
||||
verifyZeroInteractions(configDispatcher);
|
||||
verifyNoInteractions(configDispatcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -92,7 +92,7 @@ public class ConfigDispatcherFileWatcherTest {
|
||||
configDispatcherFileWatcher.processWatchEvent(null, StandardWatchEventKinds.ENTRY_DELETE,
|
||||
new File(path).toPath());
|
||||
|
||||
verifyZeroInteractions(configDispatcher);
|
||||
verifyNoInteractions(configDispatcher);
|
||||
}
|
||||
|
||||
public class TestConfigDispatcherFileWatcher extends ConfigDispatcherFileWatcher {
|
||||
|
@ -26,7 +26,7 @@ import org.eclipse.xtext.ide.server.UriExtensions;
|
||||
import org.eclipse.xtext.resource.IContainer;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.model.script.ScriptServiceUtil;
|
||||
import org.openhab.core.model.script.engine.ScriptEngine;
|
||||
|
||||
@ -51,7 +51,7 @@ public class RuntimeServerModule extends AbstractModule {
|
||||
protected void configure() {
|
||||
binder().bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class);
|
||||
|
||||
bind(UriExtensions.class).toInstance(new MappingUriExtensions(ConfigConstants.getConfigFolder()));
|
||||
bind(UriExtensions.class).toInstance(new MappingUriExtensions(OpenHAB.getConfigFolder()));
|
||||
bind(LanguageServer.class).to(LanguageServerImpl.class);
|
||||
bind(IResourceServiceProvider.Registry.class).toProvider(new RegistryProvider(scriptServiceUtil, scriptEngine));
|
||||
bind(IWorkspaceConfigFactory.class).to(ProjectWorkspaceConfigFactory.class);
|
||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.config.core.ConfigurableService;
|
||||
import org.openhab.core.storage.Storage;
|
||||
import org.openhab.core.storage.StorageService;
|
||||
@ -64,7 +64,7 @@ public class JsonStorageService implements StorageService {
|
||||
|
||||
@Activate
|
||||
protected void activate(@Nullable Map<String, Object> properties) {
|
||||
dbFolderName = ConfigConstants.getUserDataFolder() + File.separator + dbFolderName;
|
||||
dbFolderName = OpenHAB.getUserDataFolder() + File.separator + dbFolderName;
|
||||
File folder = new File(dbFolderName);
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
@ -293,7 +293,7 @@ public abstract class AbstractFileTransformationService<T> implements Transforma
|
||||
* Returns the path to the root of the transformation folder
|
||||
*/
|
||||
protected String getSourcePath() {
|
||||
return ConfigConstants.getConfigFolder() + File.separator + TransformationService.TRANSFORM_FOLDER_NAME
|
||||
return OpenHAB.getConfigFolder() + File.separator + TransformationService.TRANSFORM_FOLDER_NAME
|
||||
+ File.separator;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.i18n.TranslationProvider;
|
||||
import org.openhab.core.ui.icon.AbstractResourceIconProvider;
|
||||
import org.openhab.core.ui.icon.IconProvider;
|
||||
@ -47,8 +47,7 @@ public class CustomIconProvider extends AbstractResourceIconProvider {
|
||||
}
|
||||
|
||||
private @Nullable File getIconFile(String filename, String iconSetId) {
|
||||
File folder = new File(
|
||||
ConfigConstants.getConfigFolder() + File.separator + "icons" + File.separator + iconSetId);
|
||||
File folder = new File(OpenHAB.getConfigFolder() + File.separator + "icons" + File.separator + iconSetId);
|
||||
File file = new File(folder, filename);
|
||||
return file.exists() ? file : null;
|
||||
}
|
||||
|
@ -275,12 +275,11 @@ public class HSBType extends PercentType implements ComplexType, State, Command
|
||||
PercentType green = null;
|
||||
PercentType blue = null;
|
||||
|
||||
BigDecimal h = hue.divide(BigDecimal.valueOf(100), 10, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal h = hue.divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_UP);
|
||||
BigDecimal s = saturation.divide(BigDecimal.valueOf(100));
|
||||
|
||||
int hInt = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, BigDecimal.ROUND_HALF_UP)
|
||||
.intValue();
|
||||
BigDecimal f = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, BigDecimal.ROUND_HALF_UP)
|
||||
int hInt = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, RoundingMode.HALF_UP).intValue();
|
||||
BigDecimal f = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, RoundingMode.HALF_UP)
|
||||
.remainder(BigDecimal.ONE);
|
||||
PercentType a = new PercentType(value.multiply(BigDecimal.ONE.subtract(s)));
|
||||
PercentType b = new PercentType(value.multiply(BigDecimal.ONE.subtract(s.multiply(f))));
|
||||
@ -377,8 +376,8 @@ public class HSBType extends PercentType implements ComplexType, State, Command
|
||||
}
|
||||
|
||||
private int convertPercentToByte(PercentType percent) {
|
||||
return percent.value.multiply(BigDecimal.valueOf(255))
|
||||
.divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
return percent.value.multiply(BigDecimal.valueOf(255)).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)
|
||||
.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -52,8 +53,8 @@ public class HSBTypeTest {
|
||||
}
|
||||
|
||||
private int convertPercentToByte(PercentType percent) {
|
||||
return percent.value.multiply(BigDecimal.valueOf(255))
|
||||
.divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
return percent.value.multiply(BigDecimal.valueOf(255)).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)
|
||||
.intValue();
|
||||
}
|
||||
|
||||
private void compareHsbToRgbValues(String hsbValues, int red, int green, int blue) {
|
||||
|
@ -46,7 +46,7 @@ public class PercentTypeTest {
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
PercentType pt1 = new PercentType(new Integer(100));
|
||||
PercentType pt1 = new PercentType(Integer.valueOf(100));
|
||||
PercentType pt2 = new PercentType("100.0");
|
||||
PercentType pt3 = new PercentType(0);
|
||||
PercentType pt4 = new PercentType(0);
|
||||
|
@ -17,6 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.openhab.core.library.unit.MetricPrefix.CENTI;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
@ -83,8 +84,9 @@ public class QuantityTypeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReflectiveInstantiation() throws InstantiationException, IllegalAccessException {
|
||||
QuantityType.class.newInstance();
|
||||
public void testReflectiveInstantiation() throws InstantiationException, IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
QuantityType.class.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
|
@ -40,7 +40,7 @@ import org.junit.jupiter.api.MethodOrderer.Alphanumeric;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.test.java.JavaOSGiTest;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
import org.osgi.service.cm.Configuration;
|
||||
@ -934,16 +934,16 @@ public class ConfigDispatcherOSGiTest extends JavaOSGiTest {
|
||||
private Configuration getConfigurationWithContext(String pidWithContext) {
|
||||
String pid = null;
|
||||
String configContext = null;
|
||||
if (pidWithContext.contains(ConfigConstants.SERVICE_CONTEXT_MARKER)) {
|
||||
pid = pidWithContext.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[0];
|
||||
configContext = pidWithContext.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[1];
|
||||
if (pidWithContext.contains(OpenHAB.SERVICE_CONTEXT_MARKER)) {
|
||||
pid = pidWithContext.split(OpenHAB.SERVICE_CONTEXT_MARKER)[0];
|
||||
configContext = pidWithContext.split(OpenHAB.SERVICE_CONTEXT_MARKER)[1];
|
||||
} else {
|
||||
throw new IllegalArgumentException("PID does not have a context");
|
||||
}
|
||||
Configuration[] configs = null;
|
||||
try {
|
||||
configs = configAdmin.listConfigurations("(&(service.factoryPid=" + pid + ")("
|
||||
+ ConfigConstants.SERVICE_CONTEXT + "=" + configContext + "))");
|
||||
configs = configAdmin.listConfigurations(
|
||||
"(&(service.factoryPid=" + pid + ")(" + OpenHAB.SERVICE_CONTEXT + "=" + configContext + "))");
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"IOException occured while retrieving configuration for pid " + pidWithContext, e);
|
||||
|
@ -32,7 +32,7 @@ import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.openhab.core.library.CoreItemFactory;
|
||||
import org.openhab.core.storage.Storage;
|
||||
@ -64,13 +64,13 @@ public class JsonStorageServiceOSGiTest extends JavaOSGiTest {
|
||||
@AfterAll
|
||||
public static void afterClass() throws IOException {
|
||||
// clean up database files ...
|
||||
final Path userData = Paths.get(ConfigConstants.getUserDataFolder());
|
||||
final Path userData = Paths.get(OpenHAB.getUserDataFolder());
|
||||
if (Files.exists(userData)) {
|
||||
try (Stream<Path> walk = Files.walk(userData)) {
|
||||
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||
}
|
||||
}
|
||||
final Path config = Paths.get(ConfigConstants.getConfigFolder());
|
||||
final Path config = Paths.get(OpenHAB.getConfigFolder());
|
||||
if (Files.exists(config)) {
|
||||
try (Stream<Path> walk = Files.walk(config)) {
|
||||
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||
|
Loading…
Reference in New Issue
Block a user