mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
Removed deprecated contructors and methods (#1500)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
038f075094
commit
1fddac192b
@ -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<ItemStateConverter> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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<String, Integer> 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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user