mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-11 05:41:52 +01:00
Remove deprecated FilterCriteria methods (#1623)
Also removes "Zoned" from the getters so they follow the naming of the setters. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
f7c8505d7a
commit
aee47e6381
@ -12,9 +12,7 @@
|
||||
*/
|
||||
package org.openhab.core.persistence;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
@ -94,47 +92,11 @@ public class FilterCriteria {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Please use {@link #getBeginDateZoned()} method which returns Java 8's
|
||||
* ZonedDateTime. ZonedDateTime allows additional methods about time and time
|
||||
* zone to be added for more specific filter queries.
|
||||
*
|
||||
* @return {@link java.util.Date} object that contains information about the
|
||||
* date after which only newer entries are queried
|
||||
*/
|
||||
@Deprecated
|
||||
public Date getBeginDate() {
|
||||
if (beginDate != null) {
|
||||
return Date.from(beginDate.toInstant());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ZonedDateTime getBeginDateZoned() {
|
||||
public ZonedDateTime getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Please use {@link #getEndDateZoned()} method which returns Java 8's
|
||||
* ZonedDateTime. ZonedDateTime allows additional methods about time and time
|
||||
* zone to be added for more specific filter queries.
|
||||
*
|
||||
* @return {@link java.util.Date} object that contains information about the
|
||||
* date after which only older entries are queried
|
||||
*/
|
||||
@Deprecated
|
||||
public Date getEndDate() {
|
||||
if (endDate != null) {
|
||||
return Date.from(endDate.toInstant());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ZonedDateTime getEndDateZoned() {
|
||||
public ZonedDateTime getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
@ -163,55 +125,11 @@ public class FilterCriteria {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Please use the {@link #setBeginDate(ZonedDateTime)} method which takes Java 8's
|
||||
* ZonedDateTime as a parameter. The Date object will be converted to a
|
||||
* ZonedDateTime using the default time zone. ZonedDateTime allows additional
|
||||
* methods about time and time zone to be added for more specific filter
|
||||
* queries.
|
||||
*
|
||||
* @param beginDate A date for which to filter only newer entries.
|
||||
* @return this FilterCriteria instance, so that the methods can be easily
|
||||
* chained in order to define a filter
|
||||
*/
|
||||
@Deprecated
|
||||
public FilterCriteria setBeginDate(Date beginDate) {
|
||||
if (beginDate != null) {
|
||||
this.beginDate = ZonedDateTime.ofInstant(beginDate.toInstant(), ZoneId.systemDefault());
|
||||
} else {
|
||||
this.beginDate = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setBeginDate(ZonedDateTime beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Please use the {@link #setEndDate(ZonedDateTime)} method which takes Java 8's
|
||||
* ZonedDateTime as a parameter. The Date object will be converted to a
|
||||
* ZonedDateTime using the default time zone. ZonedDateTime allows additional
|
||||
* methods about time and time zone to be added for more specific filter
|
||||
* queries.
|
||||
*
|
||||
* @param endDate A date for which to filter only newer entries.
|
||||
* @return this FilterCriteria instance, so that the methods can be easily
|
||||
* chained in order to define a filter
|
||||
*/
|
||||
@Deprecated
|
||||
public FilterCriteria setEndDate(Date endDate) {
|
||||
if (endDate != null) {
|
||||
this.endDate = ZonedDateTime.ofInstant(endDate.toInstant(), ZoneId.systemDefault());
|
||||
} else {
|
||||
this.endDate = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setEndDate(ZonedDateTime endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
|
@ -60,11 +60,11 @@ public class TestPersistenceService implements QueryablePersistenceService {
|
||||
int startValue = 1950;
|
||||
int endValue = 2012;
|
||||
|
||||
if (filter.getBeginDateZoned() != null) {
|
||||
startValue = filter.getBeginDateZoned().getYear();
|
||||
if (filter.getBeginDate() != null) {
|
||||
startValue = filter.getBeginDate().getYear();
|
||||
}
|
||||
if (filter.getEndDateZoned() != null) {
|
||||
endValue = filter.getEndDateZoned().getYear();
|
||||
if (filter.getEndDate() != null) {
|
||||
endValue = filter.getEndDate().getYear();
|
||||
}
|
||||
|
||||
if (endValue <= startValue || startValue < 1950) {
|
||||
|
Loading…
Reference in New Issue
Block a user