diff --git a/src/main/java/net/fortuna/ical4j/model/TemporalAdapter.java b/src/main/java/net/fortuna/ical4j/model/TemporalAdapter.java index 47c19e585..7a13d81ca 100644 --- a/src/main/java/net/fortuna/ical4j/model/TemporalAdapter.java +++ b/src/main/java/net/fortuna/ical4j/model/TemporalAdapter.java @@ -35,14 +35,14 @@ public class TemporalAdapter implements Serializable { /** * A formatter capable of parsing to multiple temporal types based on the input string. */ - private static CalendarDateFormat PARSE_FORMAT = new CalendarDateFormat( + private static final CalendarDateFormat PARSE_FORMAT = new CalendarDateFormat( "yyyyMMdd['T'HHmmss[X]]", Instant::from, LocalDateTime::from, LocalDate::from); private final String valueString; private final TzId tzId; - private transient TimeZoneRegistry timeZoneRegistry; + private transient final TimeZoneRegistry timeZoneRegistry; private transient T temporal; @@ -96,6 +96,7 @@ private TemporalAdapter(String value, TzId tzId, TimeZoneRegistry timeZoneRegist this.timeZoneRegistry = timeZoneRegistry; } + @SuppressWarnings("unchecked") public T getTemporal() { if (temporal == null) { synchronized (valueString) { @@ -180,6 +181,7 @@ public ZonedDateTime toLocalTime(ZoneId zoneId) { * @return an adapter containing the parsed temporal value and format type * @throws DateTimeParseException if the string cannot be parsed */ + @SuppressWarnings("unchecked") public static TemporalAdapter parse(String value) throws DateTimeParseException { return new TemporalAdapter<>((T) PARSE_FORMAT.parse(value)); } diff --git a/src/main/java/net/fortuna/ical4j/model/property/DateProperty.java b/src/main/java/net/fortuna/ical4j/model/property/DateProperty.java index df86838e0..17e7d6a86 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/DateProperty.java +++ b/src/main/java/net/fortuna/ical4j/model/property/DateProperty.java @@ -78,14 +78,14 @@ public abstract class DateProperty extends Property { * @param name the property name * @param parameters a list of initial parameters */ - public DateProperty(final String name, final List parameters, PropertyFactory factory) { + public DateProperty(final String name, final List parameters, PropertyFactory> factory) { super(name, parameters, factory); } /** * @param name the property name */ - public DateProperty(final String name, PropertyFactory factory) { + public DateProperty(final String name, PropertyFactory> factory) { super(name, factory); } @@ -97,6 +97,7 @@ public DateProperty(final String name, PropertyFactory factory) { * * @return Returns the date. */ + @SuppressWarnings("unchecked") public T getDate() { if (date != null) { Optional tzId = getParameter(Parameter.TZID); @@ -133,6 +134,7 @@ public void setDate(T date) { * * @param value a string representation of a DATE or DATE-TIME value */ + @SuppressWarnings("unchecked") public void setValue(final String value) throws DateTimeParseException { // value can be either a date-time or a date.. if (value != null && !value.isEmpty()) { diff --git a/src/main/java/net/fortuna/ical4j/model/property/RecurrenceId.java b/src/main/java/net/fortuna/ical4j/model/property/RecurrenceId.java index 15271314a..40c265ef5 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/RecurrenceId.java +++ b/src/main/java/net/fortuna/ical4j/model/property/RecurrenceId.java @@ -38,8 +38,6 @@ import net.fortuna.ical4j.validate.ParameterValidator; import net.fortuna.ical4j.validate.ValidationException; -import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.temporal.Temporal; import java.util.List; @@ -133,13 +131,17 @@ public class RecurrenceId extends DateProperty { private static final long serialVersionUID = 4456883817126011006L; + public RecurrenceId() { + super(RECURRENCE_ID, new Factory()); + } + /** * Creates a new instance initialised with the parsed value. * * @param value the RECURRENCE_ID value string to parse */ public RecurrenceId(final String value) { - super(RECURRENCE_ID, new Factory()); + super(RECURRENCE_ID, new Factory()); setValue(value); } @@ -148,7 +150,7 @@ public RecurrenceId(final String value) { * @param aValue a value string for this component */ public RecurrenceId(final List aList, final String aValue) { - super(RECURRENCE_ID, aList, new Factory()); + super(RECURRENCE_ID, aList, new Factory()); setValue(aValue); } @@ -158,7 +160,7 @@ public RecurrenceId(final List aList, final String aValue) { * @param aDate a date representation of a date or date-time */ public RecurrenceId(final T aDate) { - super(RECURRENCE_ID, new Factory()); + super(RECURRENCE_ID, new Factory()); setDate(aDate); } @@ -169,7 +171,7 @@ public RecurrenceId(final T aDate) { * @param aDate a date representation of a date or date-time */ public RecurrenceId(final List aList, final T aDate) { - super(RECURRENCE_ID, aList, new Factory()); + super(RECURRENCE_ID, aList, new Factory()); setDate(aDate); } @@ -194,22 +196,22 @@ public final void validate() throws ValidationException { @Override public Property copy() { - return new Factory().createProperty(getParameters(), getValue()); + return new Factory().createProperty(getParameters(), getValue()); } - public static class Factory extends Content.Factory implements PropertyFactory { + public static class Factory extends Content.Factory implements PropertyFactory> { private static final long serialVersionUID = 1L; public Factory() { super(RECURRENCE_ID); } - public RecurrenceId createProperty(final List parameters, final String value) { - return new RecurrenceId(parameters, value); + public RecurrenceId createProperty(final List parameters, final String value) { + return new RecurrenceId<>(parameters, value); } - public RecurrenceId createProperty() { - return new RecurrenceId<>(LocalDateTime.now(ZoneOffset.UTC)); + public RecurrenceId createProperty() { + return new RecurrenceId<>(); } }