From 1fddac192b41ffedc07b7f6fcebf37312ba7934b Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sat, 13 Jun 2020 21:01:06 +0200 Subject: [PATCH] Removed deprecated contructors and methods (#1500) Signed-off-by: Christoph Weitkamp --- .../java/org/openhab/core/items/ItemUtil.java | 23 ----------- .../core/library/types/DateTimeType.java | 24 ----------- .../openhab/core/library/types/RawType.java | 10 ----- .../core/library/types/DateTimeTypeTest.java | 40 ------------------- .../openhab/core/items/GroupItemOSGiTest.java | 3 +- 5 files changed, 1 insertion(+), 99 deletions(-) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemUtil.java index 33d1e518b..9eed96fd4 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemUtil.java @@ -16,10 +16,6 @@ import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.core.internal.service.BundleResolverImpl; -import org.openhab.core.types.State; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; /** * The {@link ItemUtil} class contains utility methods for {@link Item} objects. @@ -117,23 +113,4 @@ public class ItemUtil { return null; } - - /** - * @deprecated use DS service {@link ItemStateConverter#convertToAcceptedState(State, Item)} instead. - */ - @Deprecated - public static @Nullable State convertToAcceptedState(@Nullable State state, Item item) { - BundleContext bundleContext = new BundleResolverImpl().resolveBundle(ItemUtil.class).getBundleContext(); - ServiceReference service = bundleContext.getServiceReference(ItemStateConverter.class); - if (service == null) { - return null; - } - - ItemStateConverter itemStateConverter = bundleContext.getService(service); - if (itemStateConverter == null) { - return null; - } - - return itemStateConverter.convertToAcceptedState(state, item); - } } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DateTimeType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DateTimeType.java index 2284ebfe4..68995192e 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DateTimeType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DateTimeType.java @@ -21,10 +21,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.zone.ZoneRulesException; -import java.util.Calendar; -import java.util.GregorianCalendar; import java.util.Locale; -import java.util.TimeZone; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -71,18 +68,6 @@ public class DateTimeType implements PrimitiveType, State, Command { private ZonedDateTime zonedDateTime; - /** - * @deprecated The constructor uses Calendar object hence it doesn't store time zone. A new constructor is - * available. Use {@link #DateTimeType(ZonedDateTime)} instead. - * - * @param calendar The Calendar object containing the time stamp. - */ - @Deprecated - public DateTimeType(Calendar calendar) { - this.zonedDateTime = ZonedDateTime.ofInstant(calendar.toInstant(), TimeZone.getDefault().toZoneId()) - .withFixedOffsetZone(); - } - public DateTimeType() { this(ZonedDateTime.now()); } @@ -93,7 +78,6 @@ public class DateTimeType implements PrimitiveType, State, Command { public DateTimeType(String zonedValue) { ZonedDateTime date = null; - try { // direct parsing (date and time) try { @@ -131,14 +115,6 @@ public class DateTimeType implements PrimitiveType, State, Command { zonedDateTime = date.withFixedOffsetZone(); } - /** - * @deprecated The method is deprecated. You can use {@link #getZonedDateTime()} instead. - */ - @Deprecated - public Calendar getCalendar() { - return GregorianCalendar.from(zonedDateTime); - } - public ZonedDateTime getZonedDateTime() { return zonedDateTime; } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/RawType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/RawType.java index 6a23deb89..4e3cc6f79 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/RawType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/RawType.java @@ -35,16 +35,6 @@ public class RawType implements PrimitiveType, State { protected byte[] bytes; protected String mimeType; - @Deprecated - public RawType() { - this(new byte[0], DEFAULT_MIME_TYPE); - } - - @Deprecated - public RawType(byte[] bytes) { - this(bytes, DEFAULT_MIME_TYPE); - } - public RawType(byte[] bytes, String mimeType) { if (mimeType.isEmpty()) { throw new IllegalArgumentException("mimeType argument must not be blank"); diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/library/types/DateTimeTypeTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/library/types/DateTimeTypeTest.java index 01b7e683c..28f23c334 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/library/types/DateTimeTypeTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/library/types/DateTimeTypeTest.java @@ -15,7 +15,6 @@ package org.openhab.core.library.types; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; -import java.text.SimpleDateFormat; import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.ZonedDateTime; @@ -256,12 +255,6 @@ public class DateTimeTypeTest { @Test public void serializationTest() { - DateTimeType dt = new DateTimeType(Calendar.getInstance()); - assertTrue(dt.equals(new DateTimeType(dt.toString()))); - } - - @Test - public void serializationTestZoned() { ZonedDateTime zoned = ZonedDateTime.now(); DateTimeType dt = new DateTimeType(zoned); DateTimeType sdt = new DateTimeType(dt.toFullString()); @@ -270,16 +263,6 @@ public class DateTimeTypeTest { @Test public void equalityTest() { - DateTimeType dt1 = new DateTimeType(Calendar.getInstance()); - DateTimeType dt2 = DateTimeType.valueOf(dt1.toFullString()); - - assertTrue(dt1.toString().equals(dt2.toString())); - assertTrue(dt1.getCalendar().equals(dt2.getCalendar())); - assertTrue(dt1.equals(dt2)); - } - - @Test - public void equalityTestZoned() { ZonedDateTime zoned = ZonedDateTime.now(); DateTimeType dt1 = new DateTimeType(zoned); DateTimeType dt2 = DateTimeType.valueOf(dt1.toFullString()); @@ -319,29 +302,6 @@ public class DateTimeTypeTest { @Test public void createDate() { - Map inputTimeMap = parameterSet.inputTimeMap; - TimeZone inputTimeZone = parameterSet.inputTimeZone; - if (inputTimeMap == null || inputTimeZone == null) { - return; - } - - // get DateTimeType from the current parameter - final Calendar calendar = Calendar.getInstance(inputTimeZone); - calendar.set(inputTimeMap.get("year"), inputTimeMap.get("month"), inputTimeMap.get("date"), - inputTimeMap.get("hourOfDay"), inputTimeMap.get("minute"), inputTimeMap.get("second")); - calendar.set(Calendar.MILLISECOND, inputTimeMap.get("milliseconds")); - DateTimeType dt1 = new DateTimeType(calendar); - DateTimeType dt2 = new DateTimeType( - new SimpleDateFormat(DateTimeType.DATE_PATTERN_WITH_TZ_AND_MS).format(calendar.getTime())); - // Test - assertEquals(dt1.toFullString(), dt1.toString()); - assertEquals(parameterSet.expectedResultLocalTZ, dt1.toString()); - assertEquals(parameterSet.expectedResultLocalTZ, dt2.toString()); - assertEquals(dt1, dt2); - } - - @Test - public void createZonedDate() { // get DateTimeType from the current parameter DateTimeType dt1; DateTimeType dt2; diff --git a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java index 9a0f262cf..a117750af 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/items/GroupItemOSGiTest.java @@ -633,7 +633,6 @@ public class GroupItemOSGiTest extends JavaOSGiTest { assertThat(groupItem.getState(), is(OnOffType.ON)); } - @SuppressWarnings("deprecation") @Test public void assertThatGroupItemChangesDoNotAffectTheGroupStatusIfnoFunctionOrBaseItemAreDefined() throws InterruptedException { @@ -646,7 +645,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest { State oldGroupState = groupItem.getState(); // State changes -> NO change event should be fired - member.setState(new RawType()); + member.setState(new RawType(new byte[0], RawType.DEFAULT_MIME_TYPE)); // wait to see that the event doesn't fire Thread.sleep(WAIT_EVENT_TO_BE_HANDLED);