From 11cd8b80c3a0f1439ed68f694f338a4eb42b6d2d Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Thu, 6 Jan 2022 12:39:20 +1100 Subject: [PATCH] Temporarily deprecate accessors to help migration to modified mutation strategy post v4.x --- .../net/fortuna/ical4j/model/Calendar.java | 17 +++++++++-- .../net/fortuna/ical4j/model/Component.java | 21 +++++-------- .../ical4j/model/ComponentContainer.java | 2 +- .../fortuna/ical4j/model/ComponentGroup.java | 2 +- .../ical4j/model/IndexedComponentList.java | 2 +- .../ical4j/model/IndexedPropertyList.java | 2 +- .../fortuna/ical4j/model/ParameterList.java | 2 +- .../net/fortuna/ical4j/model/Property.java | 30 ++++++++++++------- .../ical4j/model/PropertyContainer.java | 13 +++++++- .../fortuna/ical4j/model/PropertyList.java | 2 +- .../net/fortuna/ical4j/model/TimeZone.java | 10 +++---- .../ical4j/model/ZoneRulesBuilder.java | 20 ++++++------- .../ical4j/model/component/Observance.java | 10 +++---- .../ical4j/model/component/Participant.java | 10 +++++++ .../ical4j/model/component/VAvailability.java | 10 +++++++ .../ical4j/model/component/VEvent.java | 10 +++++++ .../ical4j/model/component/VFreeBusy.java | 14 +++++++-- .../ical4j/model/component/VJournal.java | 10 +++++++ .../ical4j/model/component/VTimeZone.java | 12 +++++++- .../fortuna/ical4j/model/component/VToDo.java | 10 +++++++ .../fortuna/ical4j/model/property/Action.java | 2 +- .../ical4j/model/property/BusyType.java | 2 +- .../ical4j/model/property/CalScale.java | 2 +- .../fortuna/ical4j/model/property/Clazz.java | 2 +- .../fortuna/ical4j/model/property/Method.java | 2 +- .../ical4j/model/property/Priority.java | 2 +- .../fortuna/ical4j/model/property/Status.java | 2 +- .../ical4j/model/property/StructuredData.java | 5 ++-- .../fortuna/ical4j/model/property/Transp.java | 2 +- .../ical4j/model/property/Version.java | 2 +- .../calendar/Rfc5545Transformer.java | 2 +- .../transform/component/VEventRule.java | 2 +- .../net/fortuna/ical4j/util/Calendars.java | 4 +-- .../fortuna/ical4j/validate/Validator.java | 10 +++---- .../component/AvailableValidator.java | 6 ++-- .../component/VAvailabilityValidator.java | 6 ++-- .../ical4j/agent/VEventUserAgentTest.groovy | 18 +++++------ .../agent/VFreeBusyUserAgentTest.groovy | 6 ++-- .../ical4j/agent/VJournalUserAgentTest.groovy | 6 ++-- .../ical4j/agent/VToDoUserAgentTest.groovy | 18 +++++------ .../ical4j/data/UnfoldingReaderSpec.groovy | 2 +- .../ical4j/model/parameter/DisplayTest.groovy | 2 +- .../ical4j/model/parameter/EmailTest.groovy | 2 +- .../ical4j/model/parameter/FeatureTest.groovy | 2 +- .../ical4j/model/parameter/LabelTest.groovy | 2 +- .../CalendarBuilderCustomRegistryTest.java | 9 +++--- .../data/CalendarBuilderTimezoneTest.java | 14 ++++----- .../ical4j/data/HCalendarParserTest.java | 2 +- .../filter/predicate/PeriodRuleTest.java | 8 ++--- .../fortuna/ical4j/model/CalendarTest.java | 16 +++++----- .../ical4j/model/IndexedPropertyListTest.java | 2 +- .../fortuna/ical4j/model/TimeZoneTest.java | 7 ++--- .../component/VAvailabilityTestCase.java | 7 +++-- .../ical4j/model/component/VEventTest.java | 30 +++++++++---------- .../ical4j/model/component/VFreeBusyTest.java | 2 +- .../ical4j/model/property/AttachTest.java | 5 ++-- .../ical4j/model/property/AttendeeTest.java | 2 +- .../ical4j/model/property/CategoriesTest.java | 8 ++--- .../model/property/DescriptionTest.java | 5 ++-- .../ical4j/model/property/ExDateTest.java | 20 ++++++------- .../ical4j/model/property/LocationTest.java | 9 +++--- .../ical4j/model/property/SummaryTest.java | 5 ++-- 62 files changed, 286 insertions(+), 185 deletions(-) diff --git a/src/main/java/net/fortuna/ical4j/model/Calendar.java b/src/main/java/net/fortuna/ical4j/model/Calendar.java index 1ff76119b..846189bb9 100644 --- a/src/main/java/net/fortuna/ical4j/model/Calendar.java +++ b/src/main/java/net/fortuna/ical4j/model/Calendar.java @@ -199,7 +199,13 @@ public final String toString() { /** * @return Returns the components. + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) */ + @Deprecated @Override public final ComponentList getComponents() { return components; @@ -212,7 +218,14 @@ public void setComponents(ComponentList components) { /** * @return Returns the properties. + * @deprecated to avoid confusion with how to mutate a PropertyList from v4.x onwards this method is temporarily + * deprecated. + * @see PropertyContainer#add(Property) + * @see PropertyContainer#remove(Property) + * @see PropertyContainer#removeAll(String...) + * @see PropertyContainer#replace(Property) */ + @Deprecated @Override public final PropertyList getProperties() { return properties; @@ -313,7 +326,7 @@ public Calendar[] split() { // if calendar contains one component or less, or is composed entirely of timezone // definitions, return the original calendar unmodified.. if (getComponents().getAll().size() <= 1 - || getComponents().get(Component.VTIMEZONE).size() == getComponents().getAll().size()) { + || getComponents(Component.VTIMEZONE).size() == getComponents().getAll().size()) { return new Calendar[] {this}; } @@ -361,7 +374,7 @@ public Calendar[] split() { public Uid getUid() throws ConstraintViolationException { Uid uid = null; for (final Component c : getComponents().getAll()) { - for (final Property foundUid : c.getProperties().get(Property.UID)) { + for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } diff --git a/src/main/java/net/fortuna/ical4j/model/Component.java b/src/main/java/net/fortuna/ical4j/model/Component.java index e0025ce06..297012827 100644 --- a/src/main/java/net/fortuna/ical4j/model/Component.java +++ b/src/main/java/net/fortuna/ical4j/model/Component.java @@ -190,7 +190,14 @@ public String getValue() { /** * @return Returns the properties. + * @deprecated to avoid confusion with how to mutate a PropertyList from v4.x onwards this method is temporarily + * deprecated. + * @see PropertyContainer#add(Property) + * @see PropertyContainer#remove(Property) + * @see PropertyContainer#removeAll(String...) + * @see PropertyContainer#replace(Property) */ + @Deprecated @Override public final PropertyList getProperties() { return properties; @@ -201,20 +208,6 @@ public void setProperties(PropertyList properties) { this.properties = properties; } - /** - * Convenience method for retrieving a required named property. - * - * @param name name of the property to retrieve - * @return the first matching property in the property list with the specified name - * @throws ConstraintViolationException when a property is not found - * - * @deprecated use {@link PropertyList#getRequired(String)} - */ - @Deprecated - public final T getRequiredProperty(String name) throws ConstraintViolationException { - return properties.getRequired(name); - } - /** * Perform validation on a component and its properties. * diff --git a/src/main/java/net/fortuna/ical4j/model/ComponentContainer.java b/src/main/java/net/fortuna/ical4j/model/ComponentContainer.java index e9148ea1c..51e687545 100644 --- a/src/main/java/net/fortuna/ical4j/model/ComponentContainer.java +++ b/src/main/java/net/fortuna/ical4j/model/ComponentContainer.java @@ -9,7 +9,7 @@ public interface ComponentContainer { void setComponents(ComponentList components); - default List getComponents(final String name) { + default List getComponents(final String... name) { return getComponents().get(name); } diff --git a/src/main/java/net/fortuna/ical4j/model/ComponentGroup.java b/src/main/java/net/fortuna/ical4j/model/ComponentGroup.java index 81e38b171..0475c4212 100644 --- a/src/main/java/net/fortuna/ical4j/model/ComponentGroup.java +++ b/src/main/java/net/fortuna/ical4j/model/ComponentGroup.java @@ -95,7 +95,7 @@ public List> calculateRecurrenceSet(final Period< List> finalPeriods = new ArrayList<>(periods); overrides.forEach(component -> { - RecurrenceId recurrenceId = component.getProperties().getRequired(Property.RECURRENCE_ID); + RecurrenceId recurrenceId = component.getRequiredProperty(Property.RECURRENCE_ID); finalPeriods.removeIf(p -> p.getStart().equals(recurrenceId.getDate())); component.calculateRecurrenceSet(period).stream() .filter(p -> p.getStart().equals(recurrenceId.getDate())) diff --git a/src/main/java/net/fortuna/ical4j/model/IndexedComponentList.java b/src/main/java/net/fortuna/ical4j/model/IndexedComponentList.java index b0ef25ad0..4d7b77fd7 100644 --- a/src/main/java/net/fortuna/ical4j/model/IndexedComponentList.java +++ b/src/main/java/net/fortuna/ical4j/model/IndexedComponentList.java @@ -53,7 +53,7 @@ public class IndexedComponentList { public IndexedComponentList(final List list, final String propertyName) { final Map> indexedComponents = new HashMap<>(); for (final T component : list) { - for (final Property property : component.getProperties().get(propertyName)) { + for (final Property property : component.getProperties(propertyName)) { List components = indexedComponents.computeIfAbsent(property.getValue(), k -> new ArrayList<>()); components.add(component); } diff --git a/src/main/java/net/fortuna/ical4j/model/IndexedPropertyList.java b/src/main/java/net/fortuna/ical4j/model/IndexedPropertyList.java index b43006cc5..412a9b85b 100644 --- a/src/main/java/net/fortuna/ical4j/model/IndexedPropertyList.java +++ b/src/main/java/net/fortuna/ical4j/model/IndexedPropertyList.java @@ -52,7 +52,7 @@ public class IndexedPropertyList { */ public IndexedPropertyList(final List list, final String parameterName) { final Map> indexedProperties = new HashMap<>(); - list.forEach(property -> property.getParameters().get(parameterName).forEach(parameter -> { + list.forEach(property -> property.getParameters(parameterName).forEach(parameter -> { List properties = indexedProperties.computeIfAbsent(parameter.getValue(), k -> new ArrayList<>()); properties.add(property); })); diff --git a/src/main/java/net/fortuna/ical4j/model/ParameterList.java b/src/main/java/net/fortuna/ical4j/model/ParameterList.java index a310e099f..9ea467f49 100644 --- a/src/main/java/net/fortuna/ical4j/model/ParameterList.java +++ b/src/main/java/net/fortuna/ical4j/model/ParameterList.java @@ -136,7 +136,7 @@ public final Optional getParameter(final String aName) * @param name name of parameters to return * @return a parameter list * - * @deprecated use {@link ParameterList#get(String)} + * @deprecated use {@link ParameterList#get(String...)} */ @Deprecated public final ParameterList getParameters(final String name) { diff --git a/src/main/java/net/fortuna/ical4j/model/Property.java b/src/main/java/net/fortuna/ical4j/model/Property.java index 6c9d6a83c..6fe7e5903 100644 --- a/src/main/java/net/fortuna/ical4j/model/Property.java +++ b/src/main/java/net/fortuna/ical4j/model/Property.java @@ -41,11 +41,10 @@ import java.io.IOException; import java.net.URISyntaxException; -import java.text.ParseException; import java.util.Comparator; -import java.util.function.Function; import java.util.List; import java.util.Optional; +import java.util.function.Function; /** * Defines an iCalendar property. Subclasses of this class provide additional validation and typed values for specific @@ -470,7 +469,14 @@ public final String getName() { /** * @return Returns the parameters. + * @deprecated to avoid confusion with how to mutate a {@link ParameterList} from v4.x onwards this method is temporarily + * deprecated. + * @see Property#add(Parameter) + * @see Property#remove(Parameter) + * @see Property#removeAll(String...) + * @see Property#replace(Parameter) */ + @Deprecated public final ParameterList getParameters() { return parameters; } @@ -507,7 +513,7 @@ public T remove(Parameter parameter) { * @return a reference to the property to support method chaining */ @SuppressWarnings("unchecked") - public T removeAll(String parameterName) { + public T removeAll(String... parameterName) { setParameters((ParameterList) parameters.removeAll(parameterName)); return (T) this; } @@ -528,11 +534,8 @@ public T replace(Parameter parameter) { * * @param name name of parameters to retrieve * @return a parameter list containing only parameters with the specified name - * - * @deprecated use {@link ParameterList#get(String)} */ - @Deprecated - public final List getParameters(final String name) { + public final List getParameters(final String... name) { return getParameters().get(name); } @@ -541,14 +544,21 @@ public final List getParameters(final String name) { * * @param name name of the parameter to retrieve * @return the first parameter from the parameter list with the specified name - * - * @deprecated use {@link ParameterList#getFirst(String)} */ - @Deprecated public final

Optional

getParameter(final String name) { return getParameters().getFirst(name); } + /** + * Retrieve a single required parameter. + * @param name + * @param

+ * @return + */ + public final

P getRequiredParameter(final String name) { + return getParameters().getRequired(name); + } + /** * Sets the current value of the property. * diff --git a/src/main/java/net/fortuna/ical4j/model/PropertyContainer.java b/src/main/java/net/fortuna/ical4j/model/PropertyContainer.java index 53c5d4c70..7f137a044 100644 --- a/src/main/java/net/fortuna/ical4j/model/PropertyContainer.java +++ b/src/main/java/net/fortuna/ical4j/model/PropertyContainer.java @@ -9,7 +9,7 @@ public interface PropertyContainer { void setProperties(PropertyList properties); - default List getProperties(final String name) { + default List getProperties(final String... name) { return getProperties().get(name); } @@ -17,6 +17,17 @@ default Optional getProperty(final String name) { return getProperties().getFirst(name); } + /** + * Convenience method for retrieving a required named property. + * + * @param name name of the property to retrieve + * @return the first matching property in the property list with the specified name + * @throws ConstraintViolationException when a property is not found + */ + default T getRequiredProperty(String name) throws ConstraintViolationException { + return getProperties().getRequired(name); + } + /** * Add a property to the container. * @param property the property to add diff --git a/src/main/java/net/fortuna/ical4j/model/PropertyList.java b/src/main/java/net/fortuna/ical4j/model/PropertyList.java index e283c35fc..6501c2c0b 100644 --- a/src/main/java/net/fortuna/ical4j/model/PropertyList.java +++ b/src/main/java/net/fortuna/ical4j/model/PropertyList.java @@ -133,7 +133,7 @@ public final Optional getProperty(final String aName) { * @param name name of properties to return * @return a property list * - * @deprecated use {@link PropertyList#get(String)} + * @deprecated use {@link PropertyList#get(String...)} */ @Deprecated public final List getProperties(final String name) { diff --git a/src/main/java/net/fortuna/ical4j/model/TimeZone.java b/src/main/java/net/fortuna/ical4j/model/TimeZone.java index ad70d75a4..2437b2a19 100644 --- a/src/main/java/net/fortuna/ical4j/model/TimeZone.java +++ b/src/main/java/net/fortuna/ical4j/model/TimeZone.java @@ -103,7 +103,7 @@ public final int getOffset(final int era, final int year, final int month, final OffsetDateTime date = OffsetDateTime.of(year, month + 1, dayOfMonth, hour, minute, second, ms * 1000, ZoneOffset.ofTotalSeconds(getRawOffset() / 1000)); final Observance observance = vTimeZone.getApplicableObservance(date); if (observance != null) { - final TzOffsetTo offset = observance.getProperties().getRequired(Property.TZOFFSETTO); + final TzOffsetTo offset = observance.getRequiredProperty(Property.TZOFFSETTO); return (int) (offset.getOffset().getTotalSeconds() * 1000L); } return 0; @@ -116,7 +116,7 @@ public final int getOffset(final int era, final int year, final int month, final public int getOffset(long date) { final Observance observance = vTimeZone.getApplicableObservance(Instant.ofEpochMilli(date)); if (observance != null) { - final TzOffsetTo offset = observance.getProperties().getRequired(Property.TZOFFSETTO); + final TzOffsetTo offset = observance.getRequiredProperty(Property.TZOFFSETTO); if ((offset.getOffset().getTotalSeconds() * 1000L) < getRawOffset()) { return getRawOffset(); } else { @@ -162,7 +162,7 @@ public final void setRawOffset(final int offsetMillis) { */ @Override public final boolean useDaylightTime() { - final List daylights = vTimeZone.getObservances().get(Observance.DAYLIGHT); + final List daylights = vTimeZone.getComponents(Observance.DAYLIGHT); return (!daylights.isEmpty()); } @@ -175,10 +175,10 @@ public final VTimeZone getVTimeZone() { private static int getRawOffset(VTimeZone vt) { - List seasonalTimes = vt.getObservances().get(Observance.STANDARD); + List seasonalTimes = vt.getComponents(Observance.STANDARD); // if no standard time use daylight time.. if (seasonalTimes.isEmpty()) { - seasonalTimes = vt.getObservances().get(Observance.DAYLIGHT); + seasonalTimes = vt.getComponents(Observance.DAYLIGHT); if (seasonalTimes.isEmpty()) { return 0; } diff --git a/src/main/java/net/fortuna/ical4j/model/ZoneRulesBuilder.java b/src/main/java/net/fortuna/ical4j/model/ZoneRulesBuilder.java index e31b6c18e..127d167dc 100644 --- a/src/main/java/net/fortuna/ical4j/model/ZoneRulesBuilder.java +++ b/src/main/java/net/fortuna/ical4j/model/ZoneRulesBuilder.java @@ -32,7 +32,7 @@ private List buildTransitions(List observances for (Observance observance : observances) { // ignore transitions that have no effect.. Optional offsetFrom = observance.getProperties().getFirst(Property.TZOFFSETFROM); - TzOffsetTo offsetTo = observance.getProperties().getRequired(Property.TZOFFSETTO); + TzOffsetTo offsetTo = observance.getRequiredProperty(Property.TZOFFSETTO); if (offsetFrom.isPresent() && !offsetFrom.get().getOffset().equals(offsetTo.getOffset())) { Optional> startDate = observance.getProperties().getFirst(Property.DTSTART); @@ -51,9 +51,9 @@ private Set buildTransitionRules(List obse Set transitionRules = new HashSet<>(); for (Observance observance : observances) { Optional> rrule = observance.getProperties().getFirst(Property.RRULE); - TzOffsetFrom offsetFrom = observance.getProperties().getRequired(Property.TZOFFSETFROM); - TzOffsetTo offsetTo = observance.getProperties().getRequired(Property.TZOFFSETTO); - DtStart startDate = observance.getProperties().getRequired(Property.DTSTART); + TzOffsetFrom offsetFrom = observance.getRequiredProperty(Property.TZOFFSETFROM); + TzOffsetTo offsetTo = observance.getRequiredProperty(Property.TZOFFSETTO); + DtStart startDate = observance.getRequiredProperty(Property.DTSTART); // ignore invalid rules if (rrule.isPresent() && !rrule.get().getRecur().getMonthList().isEmpty()) { @@ -75,24 +75,24 @@ private Set buildTransitionRules(List obse public ZoneRules build() throws ConstraintViolationException { Observance current = VTimeZone.getApplicableObservance(Instant.now(), - vTimeZone.getObservances().get(Observance.STANDARD)); + vTimeZone.getComponents(Observance.STANDARD)); // if no standard time use daylight time.. if (current == null) { current = VTimeZone.getApplicableObservance(Instant.now(), - vTimeZone.getObservances().get(Observance.DAYLIGHT)); + vTimeZone.getComponents(Observance.DAYLIGHT)); } - TzOffsetFrom offsetFrom = current.getProperties().getRequired(Property.TZOFFSETFROM); - TzOffsetTo offsetTo = current.getProperties().getRequired(Property.TZOFFSETTO); + TzOffsetFrom offsetFrom = current.getRequiredProperty(Property.TZOFFSETFROM); + TzOffsetTo offsetTo = current.getRequiredProperty(Property.TZOFFSETTO); ZoneOffset standardOffset = offsetTo.getOffset(); ZoneOffset wallOffset = offsetFrom.getOffset(); List standardOffsetTransitions = buildTransitions( - vTimeZone.getObservances().get(Observance.STANDARD)); + vTimeZone.getComponents(Observance.STANDARD)); Collections.sort(standardOffsetTransitions); List offsetTransitions = buildTransitions( - vTimeZone.getObservances().get(Observance.DAYLIGHT)); + vTimeZone.getComponents(Observance.DAYLIGHT)); Collections.sort(offsetTransitions); Set transitionRules = buildTransitionRules( vTimeZone.getObservances().getAll(), standardOffset); diff --git a/src/main/java/net/fortuna/ical4j/model/component/Observance.java b/src/main/java/net/fortuna/ical4j/model/component/Observance.java index 28f5babf6..328206903 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/Observance.java +++ b/src/main/java/net/fortuna/ical4j/model/component/Observance.java @@ -146,9 +146,9 @@ public final OffsetDateTime getLatestOnset(final Temporal date) { throw new UnsupportedOperationException("Unable to get timezone observance for date-only temporal."); } - TzOffsetTo offsetTo = getProperties().getRequired(TZOFFSETTO); + TzOffsetTo offsetTo = getRequiredProperty(TZOFFSETTO); - TzOffsetFrom offsetFrom = getProperties().getRequired(TZOFFSETFROM); + TzOffsetFrom offsetFrom = getRequiredProperty(TZOFFSETFROM); OffsetDateTime offsetDate = LocalDateTime.ofInstant(Instant.from(date), ZoneOffset.UTC).atOffset( offsetTo.getOffset()); @@ -159,7 +159,7 @@ public final OffsetDateTime getLatestOnset(final Temporal date) { if (initialOnset == null) { try { - DtStart dtStart = getProperties().getRequired(DTSTART); + DtStart dtStart = getRequiredProperty(DTSTART); if (dtStart.getDate().isSupported(ChronoField.HOUR_OF_DAY)) { initialOnset = LocalDateTime.from(dtStart.getDate()).atOffset(offsetFrom.getOffset()); } else { @@ -191,7 +191,7 @@ public final OffsetDateTime getLatestOnset(final Temporal date) { cacheableOnsets.add(initialOnset); // check rdates for latest applicable onset.. - final List> rdates = getProperties().get(RDATE); + final List> rdates = getProperties(RDATE); for (RDate rdate : rdates) { List rdateDates = rdate.getDates(); for (final LocalDateTime rdateDate : rdateDates) { @@ -208,7 +208,7 @@ public final OffsetDateTime getLatestOnset(final Temporal date) { } // check recurrence rules for latest applicable onset.. - final List> rrules = getProperties().get(RRULE); + final List> rrules = getProperties(RRULE); for (RRule rrule : rrules) { // include future onsets to determine onset period.. onsetLimit = offsetDate.plus(10, ChronoUnit.YEARS); diff --git a/src/main/java/net/fortuna/ical4j/model/component/Participant.java b/src/main/java/net/fortuna/ical4j/model/component/Participant.java index 4c7808860..ee776490e 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/Participant.java +++ b/src/main/java/net/fortuna/ical4j/model/component/Participant.java @@ -164,6 +164,16 @@ public final void validate(final boolean recurse) throws ValidationException { } } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VAvailability.java b/src/main/java/net/fortuna/ical4j/model/component/VAvailability.java index 208b15ee3..6cfbc5906 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VAvailability.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VAvailability.java @@ -150,6 +150,16 @@ public final ComponentList getAvailable() { return getComponents(); } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VEvent.java b/src/main/java/net/fortuna/ical4j/model/component/VEvent.java index 736f074f4..72db280fd 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VEvent.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VEvent.java @@ -330,6 +330,16 @@ public final ComponentList getAlarms() { return (ComponentList) components; } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VFreeBusy.java b/src/main/java/net/fortuna/ical4j/model/component/VFreeBusy.java index b232b149a..6c0d25a63 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VFreeBusy.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VFreeBusy.java @@ -322,8 +322,8 @@ public VFreeBusy(final VFreeBusy request, final List componen final DtStart start; final DtEnd end; - start = request.getProperties().getRequired(DTSTART); - end = request.getProperties().getRequired(DTEND); + start = request.getRequiredProperty(DTSTART); + end = request.getRequiredProperty(DTEND); // ensure the request is valid.. request.validate(); @@ -514,6 +514,16 @@ public void validate(Method method) throws ValidationException { } } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VJournal.java b/src/main/java/net/fortuna/ical4j/model/component/VJournal.java index 3e1278423..b3f11a2c2 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VJournal.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VJournal.java @@ -191,6 +191,16 @@ public void validate(Method method) throws ValidationException { } } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VTimeZone.java b/src/main/java/net/fortuna/ical4j/model/component/VTimeZone.java index 5ebf0d0c7..35c7a3155 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VTimeZone.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VTimeZone.java @@ -158,7 +158,7 @@ public VTimeZone(final PropertyList properties) { * @param observances a list of type components */ public VTimeZone(final ComponentList observances) { - super(VTIMEZONE); + this(new PropertyList(), observances); } /** @@ -210,6 +210,16 @@ public final ComponentList getObservances() { return (ComponentList) components; } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/component/VToDo.java b/src/main/java/net/fortuna/ical4j/model/component/VToDo.java index 230a6022c..d7ef2e3ca 100644 --- a/src/main/java/net/fortuna/ical4j/model/component/VToDo.java +++ b/src/main/java/net/fortuna/ical4j/model/component/VToDo.java @@ -248,6 +248,16 @@ public final ComponentList getAlarms() { return (ComponentList) components; } + /** + * + * @return + * @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily + * deprecated. + * @see ComponentContainer#add(Component) + * @see ComponentContainer#remove(Component) + * @see ComponentContainer#replace(Component) + */ + @Deprecated @Override public ComponentList getComponents() { return (ComponentList) components; diff --git a/src/main/java/net/fortuna/ical4j/model/property/Action.java b/src/main/java/net/fortuna/ical4j/model/property/Action.java index 070a310f9..1e2238ae7 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Action.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Action.java @@ -110,7 +110,7 @@ public void setValue(final String aValue) { } @Override - public ImmutableAction removeAll(String parameterName) { + public ImmutableAction removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/BusyType.java b/src/main/java/net/fortuna/ical4j/model/property/BusyType.java index 52b35e6d1..78fb149b8 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/BusyType.java +++ b/src/main/java/net/fortuna/ical4j/model/property/BusyType.java @@ -111,7 +111,7 @@ public ImmutableBusyType remove(Parameter parameter) { } @Override - public ImmutableBusyType removeAll(String parameterName) { + public ImmutableBusyType removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/CalScale.java b/src/main/java/net/fortuna/ical4j/model/property/CalScale.java index b2ae9a155..e6022657b 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/CalScale.java +++ b/src/main/java/net/fortuna/ical4j/model/property/CalScale.java @@ -89,7 +89,7 @@ public void setValue(final String aValue) { } @Override - public ImmutableCalScale removeAll(String parameterName) { + public ImmutableCalScale removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/Clazz.java b/src/main/java/net/fortuna/ical4j/model/property/Clazz.java index bcbdaf6f4..bc718dc34 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Clazz.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Clazz.java @@ -144,7 +144,7 @@ public void setValue(final String aValue) { } @Override - public ImmutableClazz removeAll(String parameterName) { + public ImmutableClazz removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/Method.java b/src/main/java/net/fortuna/ical4j/model/property/Method.java index 202e18033..9d19f7755 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Method.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Method.java @@ -124,7 +124,7 @@ public ImmutableMethod remove(Parameter parameter) { } @Override - public ImmutableMethod removeAll(String parameterName) { + public ImmutableMethod removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/Priority.java b/src/main/java/net/fortuna/ical4j/model/property/Priority.java index 83ca3ae1a..cd6209bc5 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Priority.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Priority.java @@ -177,7 +177,7 @@ public ImmutablePriority remove(Parameter parameter) { } @Override - public ImmutablePriority removeAll(String parameterName) { + public ImmutablePriority removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/Status.java b/src/main/java/net/fortuna/ical4j/model/property/Status.java index 1d1964a7b..685166ba4 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Status.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Status.java @@ -205,7 +205,7 @@ public ImmutableStatus remove(Parameter parameter) { } @Override - public ImmutableStatus removeAll(String parameterName) { + public ImmutableStatus removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/StructuredData.java b/src/main/java/net/fortuna/ical4j/model/property/StructuredData.java index 59bcbdc1d..388643220 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/StructuredData.java +++ b/src/main/java/net/fortuna/ical4j/model/property/StructuredData.java @@ -45,7 +45,6 @@ import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; -import java.text.ParseException; /** * $Id$ @@ -97,7 +96,7 @@ public final void setValue(final String aValue) throws URISyntaxException { // binary = Base64.decode(aValue); try { final BinaryDecoder decoder = DecoderFactory.getInstance() - .createBinaryDecoder(getParameters().getRequired(Parameter.ENCODING)); + .createBinaryDecoder(getRequiredParameter(Parameter.ENCODING)); binary = decoder.decode(aValue.getBytes()); } catch (UnsupportedEncodingException uee) { Logger log = LoggerFactory.getLogger(Attach.class); @@ -106,7 +105,7 @@ public final void setValue(final String aValue) throws URISyntaxException { Logger log = LoggerFactory.getLogger(Attach.class); log.error("Error decoding binary data", de); } - } else if (Value.URI.equals(getParameters().getRequired(Parameter.VALUE))) { + } else if (Value.URI.equals(getRequiredParameter(Parameter.VALUE))) { uri = Uris.create(aValue); value = aValue; // assume text.. diff --git a/src/main/java/net/fortuna/ical4j/model/property/Transp.java b/src/main/java/net/fortuna/ical4j/model/property/Transp.java index 862879efa..f412e8b7a 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Transp.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Transp.java @@ -133,7 +133,7 @@ public ImmutableTransp remove(Parameter parameter) { } @Override - public ImmutableTransp removeAll(String parameterName) { + public ImmutableTransp removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/model/property/Version.java b/src/main/java/net/fortuna/ical4j/model/property/Version.java index e5df92f37..c2d96c6a6 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/Version.java +++ b/src/main/java/net/fortuna/ical4j/model/property/Version.java @@ -97,7 +97,7 @@ public ImmutableVersion remove(Parameter parameter) { } @Override - public ImmutableVersion removeAll(String parameterName) { + public ImmutableVersion removeAll(String... parameterName) { throwException(); return null; } diff --git a/src/main/java/net/fortuna/ical4j/transform/calendar/Rfc5545Transformer.java b/src/main/java/net/fortuna/ical4j/transform/calendar/Rfc5545Transformer.java index 2c0be432d..e2f3f0558 100644 --- a/src/main/java/net/fortuna/ical4j/transform/calendar/Rfc5545Transformer.java +++ b/src/main/java/net/fortuna/ical4j/transform/calendar/Rfc5545Transformer.java @@ -69,7 +69,7 @@ private enum CountableProperties{ } protected void limitApparitionsNumberIn(Component component){ - List propertyList = component.getProperties().get(name); + List propertyList = component.getProperties(name); if(propertyList.size() <= maxApparitionNumber){ return; diff --git a/src/main/java/net/fortuna/ical4j/transform/component/VEventRule.java b/src/main/java/net/fortuna/ical4j/transform/component/VEventRule.java index fc0da7daa..71c96aeb5 100644 --- a/src/main/java/net/fortuna/ical4j/transform/component/VEventRule.java +++ b/src/main/java/net/fortuna/ical4j/transform/component/VEventRule.java @@ -55,7 +55,7 @@ public void applyTo(VEvent element) { } } - List dtStamps = element.getProperties().get(Property.DTSTAMP); + List dtStamps = element.getProperties(Property.DTSTAMP); if (dtStamps.isEmpty()) { element.add(new DtStamp()); } diff --git a/src/main/java/net/fortuna/ical4j/util/Calendars.java b/src/main/java/net/fortuna/ical4j/util/Calendars.java index cbd7061ed..8a7ac5ac7 100644 --- a/src/main/java/net/fortuna/ical4j/util/Calendars.java +++ b/src/main/java/net/fortuna/ical4j/util/Calendars.java @@ -142,7 +142,7 @@ public static Calendar[] split(final Calendar calendar) { // if calendar contains one component or less, or is composed entirely of timezone // definitions, return the original calendar unmodified.. if (calendar.getComponents().getAll().size() <= 1 - || calendar.getComponents().get(Component.VTIMEZONE).size() == calendar.getComponents().getAll().size()) { + || calendar.getComponents(Component.VTIMEZONE).size() == calendar.getComponents().getAll().size()) { return new Calendar[] {calendar}; } @@ -192,7 +192,7 @@ public static Calendar[] split(final Calendar calendar) { public static Uid getUid(final Calendar calendar) throws ConstraintViolationException { Uid uid = null; for (final Component c : calendar.getComponents().getAll()) { - for (final Property foundUid : c.getProperties().get(Property.UID)) { + for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } diff --git a/src/main/java/net/fortuna/ical4j/validate/Validator.java b/src/main/java/net/fortuna/ical4j/validate/Validator.java index e6215b35d..0bdc779e2 100644 --- a/src/main/java/net/fortuna/ical4j/validate/Validator.java +++ b/src/main/java/net/fortuna/ical4j/validate/Validator.java @@ -154,27 +154,27 @@ default List apply(ValidationRule rule, default List apply(ValidationRule rule, Property target) { if (rule.getPredicate().test(target)) { - int total = rule.getInstances().stream().mapToInt(s -> target.getParameters().get(s).size()).sum(); + int total = rule.getInstances().stream().mapToInt(s -> target.getParameters(s).size()).sum(); switch (rule.getType()) { case None: return rule.getInstances().stream().filter(s -> target.getParameters().getFirst(s).isPresent()) .map(s -> String.format("%s %s", rule.getType().getDescription(), s)) .collect(Collectors.toList()); case One: - return rule.getInstances().stream().filter(s -> target.getParameters().get(s).size() != 1) + return rule.getInstances().stream().filter(s -> target.getParameters(s).size() != 1) .map(s -> String.format("%s %s", rule.getType().getDescription(), s)) .collect(Collectors.toList()); case OneOrLess: - return rule.getInstances().stream().filter(s -> target.getParameters().get(s).size() > 1) + return rule.getInstances().stream().filter(s -> target.getParameters(s).size() > 1) .map(s -> String.format("%s %s", rule.getType().getDescription(), s)) .collect(Collectors.toList()); case OneOrMore: - return rule.getInstances().stream().filter(s -> target.getParameters().get(s).size() < 1) + return rule.getInstances().stream().filter(s -> target.getParameters(s).size() < 1) .map(s -> String.format("%s %s", rule.getType().getDescription(), s)) .collect(Collectors.toList()); case OneExclusive: for (String instance : rule.getInstances()) { - int count = target.getParameters().get(instance).size(); + int count = target.getParameters(instance).size(); if (count > 0 && count != total) { return Collections.singletonList( String.format("%s %s", rule.getType().getDescription(), diff --git a/src/main/java/net/fortuna/ical4j/validate/component/AvailableValidator.java b/src/main/java/net/fortuna/ical4j/validate/component/AvailableValidator.java index 018d0b158..7b2e6cd00 100644 --- a/src/main/java/net/fortuna/ical4j/validate/component/AvailableValidator.java +++ b/src/main/java/net/fortuna/ical4j/validate/component/AvailableValidator.java @@ -59,8 +59,8 @@ public void validate(Available target) throws ValidationException { * "DATE-TIME" values specified as either date with UTC time or date * with local time and a time zone reference. */ - final DtStart start = target.getProperties().getRequired(Property.DTSTART); - if (Value.DATE.equals(start.getParameters().getRequired(Parameter.VALUE))) { + final DtStart start = target.getRequiredProperty(Property.DTSTART); + if (Value.DATE.equals(start.getRequiredParameter(Parameter.VALUE))) { result.getErrors().add("Property [" + Property.DTSTART + "] must be a " + Value.DATE_TIME); } @@ -73,7 +73,7 @@ public void validate(Available target) throws ValidationException { */ final Optional> end = target.getProperty(Property.DTEND); /* Must be DATE_TIME */ - if (end.isPresent() && Value.DATE.equals(end.get().getParameters().getRequired(Parameter.VALUE))) { + if (end.isPresent() && Value.DATE.equals(end.get().getRequiredParameter(Parameter.VALUE))) { result.getErrors().add("Property [" + Property.DTEND + "] must be a " + Value.DATE_TIME); } diff --git a/src/main/java/net/fortuna/ical4j/validate/component/VAvailabilityValidator.java b/src/main/java/net/fortuna/ical4j/validate/component/VAvailabilityValidator.java index a33180046..38275a52a 100644 --- a/src/main/java/net/fortuna/ical4j/validate/component/VAvailabilityValidator.java +++ b/src/main/java/net/fortuna/ical4j/validate/component/VAvailabilityValidator.java @@ -70,14 +70,14 @@ public void validate(VAvailability target) throws ValidationException { * "DATE-TIME" values specified as either date with UTC time or date * with local time and a time zone reference. */ - final DtStart start = target.getProperties().getRequired(Property.DTSTART); - if (Value.DATE.equals(start.getParameters().getRequired(Parameter.VALUE))) { + final DtStart start = target.getRequiredProperty(Property.DTSTART); + if (Value.DATE.equals(start.getRequiredParameter(Parameter.VALUE))) { result.getErrors().add("Property [" + Property.DTSTART + "] must be a " + Value.DATE_TIME); } /* Must be DATE_TIME */ final Optional> end = target.getProperty(Property.DTEND); - if (end.isPresent() && Value.DATE.equals(end.get().getParameters().getRequired(Parameter.VALUE))) { + if (end.isPresent() && Value.DATE.equals(end.get().getRequiredParameter(Parameter.VALUE))) { result.getErrors().add("Property [" + Property.DTEND + "] must be a " + Value.DATE_TIME); } diff --git a/src/test/groovy/net/fortuna/ical4j/agent/VEventUserAgentTest.groovy b/src/test/groovy/net/fortuna/ical4j/agent/VEventUserAgentTest.groovy index 82b06e6d1..b7023325c 100644 --- a/src/test/groovy/net/fortuna/ical4j/agent/VEventUserAgentTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/agent/VEventUserAgentTest.groovy @@ -44,7 +44,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.publish(vevent, vevent2) then: 'the calendar object contains method = PUBLISH' - calendar.getProperties().getRequired(Property.METHOD) == Method.PUBLISH + calendar.getRequiredProperty(Property.METHOD) == Method.PUBLISH and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperties().getFirst(Property.SEQUENCE).isPresent() } @@ -78,7 +78,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.request(vevent, vevent2) then: 'the calendar object contains method = REQUEST' - calendar.getProperties().getRequired(Property.METHOD) == Method.REQUEST + calendar.getRequiredProperty(Property.METHOD) == Method.REQUEST and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperties().getFirst(Property.SEQUENCE).isPresent() } @@ -105,7 +105,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.delegate(request) then: 'the calendar object contains method = REQUEST' - calendar.getProperties().getRequired(Property.METHOD) == Method.REQUEST + calendar.getRequiredProperty(Property.METHOD) == Method.REQUEST } def "Reply"() { @@ -129,7 +129,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.reply(request) then: 'the calendar object contains method = REPLY' - calendar.getProperties().getRequired(Property.METHOD) == Method.REPLY + calendar.getRequiredProperty(Property.METHOD) == Method.REPLY } def "Add"() { @@ -147,7 +147,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.add(vevent) then: 'the calendar object contains method = ADD' - calendar.getProperties().getRequired(Property.METHOD) == Method.ADD + calendar.getRequiredProperty(Property.METHOD) == Method.ADD } def "Cancel"() { @@ -164,7 +164,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.cancel(vevent) then: 'the calendar object contains method = CANCEL' - calendar.getProperties().getRequired(Property.METHOD) == Method.CANCEL + calendar.getRequiredProperty(Property.METHOD) == Method.CANCEL } def "Refresh"() { @@ -182,7 +182,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.refresh(vevent) then: 'the calendar object contains method = REFRESH' - calendar.getProperties().getRequired(Property.METHOD) == Method.REFRESH + calendar.getRequiredProperty(Property.METHOD) == Method.REFRESH } def "Counter"() { @@ -206,7 +206,7 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.counter(request) then: 'the calendar object contains method = COUNTER' - calendar.getProperties().getRequired(Property.METHOD) == Method.COUNTER + calendar.getRequiredProperty(Property.METHOD) == Method.COUNTER } def "DeclineCounter"() { @@ -227,6 +227,6 @@ class VEventUserAgentTest extends Specification { def calendar = userAgent.declineCounter(counter) then: 'the calendar object contains method = DECLINECOUNTER' - calendar.getProperties().getRequired(Property.METHOD) == Method.DECLINE_COUNTER + calendar.getRequiredProperty(Property.METHOD) == Method.DECLINE_COUNTER } } diff --git a/src/test/groovy/net/fortuna/ical4j/agent/VFreeBusyUserAgentTest.groovy b/src/test/groovy/net/fortuna/ical4j/agent/VFreeBusyUserAgentTest.groovy index 71a3f04ab..777139f35 100644 --- a/src/test/groovy/net/fortuna/ical4j/agent/VFreeBusyUserAgentTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/agent/VFreeBusyUserAgentTest.groovy @@ -52,7 +52,7 @@ class VFreeBusyUserAgentTest extends Specification { def calendar = userAgent.publish(result) then: 'the calendar object contains method = PUBLISH' - calendar.getProperties().getRequired(Property.METHOD) == Method.PUBLISH + calendar.getRequiredProperty(Property.METHOD) == Method.PUBLISH and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperty(Property.SEQUENCE).isPresent() } @@ -84,7 +84,7 @@ class VFreeBusyUserAgentTest extends Specification { def calendar = userAgent.request(vfreeBusy, vfreeBusy2) then: 'the calendar object contains method = REQUEST' - calendar.getProperties().getRequired(Property.METHOD) == Method.REQUEST + calendar.getRequiredProperty(Property.METHOD) == Method.REQUEST and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperty(Property.SEQUENCE).isPresent() } @@ -130,7 +130,7 @@ class VFreeBusyUserAgentTest extends Specification { def calendar = userAgent.reply(request) then: 'the calendar object contains method = REPLY' - calendar.getProperties().getRequired(Property.METHOD) == Method.REPLY + calendar.getRequiredProperty(Property.METHOD) == Method.REPLY } def "Add"() { diff --git a/src/test/groovy/net/fortuna/ical4j/agent/VJournalUserAgentTest.groovy b/src/test/groovy/net/fortuna/ical4j/agent/VJournalUserAgentTest.groovy index 52a724d0e..356f13bd0 100644 --- a/src/test/groovy/net/fortuna/ical4j/agent/VJournalUserAgentTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/agent/VJournalUserAgentTest.groovy @@ -41,7 +41,7 @@ class VJournalUserAgentTest extends Specification { def calendar = userAgent.publish(vjournal, vjournal2) then: 'the calendar object contains method = PUBLISH' - calendar.getProperties().getRequired(Property.METHOD) == Method.PUBLISH + calendar.getRequiredProperty(Property.METHOD) == Method.PUBLISH and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperties().getFirst(Property.SEQUENCE).isPresent() } @@ -124,7 +124,7 @@ class VJournalUserAgentTest extends Specification { def calendar = userAgent.add(vjournal) then: 'the calendar object contains method = ADD' - calendar.getProperties().getRequired(Property.METHOD) == Method.ADD + calendar.getRequiredProperty(Property.METHOD) == Method.ADD } def "Cancel"() { @@ -140,7 +140,7 @@ class VJournalUserAgentTest extends Specification { def calendar = userAgent.cancel(vjournal) then: 'the calendar object contains method = CANCEL' - calendar.getProperties().getRequired(Property.METHOD) == Method.CANCEL + calendar.getRequiredProperty(Property.METHOD) == Method.CANCEL } def "Refresh"() { diff --git a/src/test/groovy/net/fortuna/ical4j/agent/VToDoUserAgentTest.groovy b/src/test/groovy/net/fortuna/ical4j/agent/VToDoUserAgentTest.groovy index 28dbef110..91045c64f 100644 --- a/src/test/groovy/net/fortuna/ical4j/agent/VToDoUserAgentTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/agent/VToDoUserAgentTest.groovy @@ -43,7 +43,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.publish(vtodo, vtodo2) then: 'the calendar object contains method = PUBLISH' - calendar.getProperties().getRequired(Property.METHOD) == Method.PUBLISH + calendar.getRequiredProperty(Property.METHOD) == Method.PUBLISH and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperties().getFirst(Property.SEQUENCE).isPresent() } @@ -79,7 +79,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.request(vtodo, vtodo2) then: 'the calendar object contains method = REQUEST' - calendar.getProperties().getRequired(Property.METHOD) == Method.REQUEST + calendar.getRequiredProperty(Property.METHOD) == Method.REQUEST and: 'the sequence property is present on all components' calendar.components.all.each { it.getProperties().getFirst(Property.SEQUENCE).isPresent() } @@ -108,7 +108,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.delegate(request) then: 'the calendar object contains method = REQUEST' - calendar.getProperties().getRequired(Property.METHOD) == Method.REQUEST + calendar.getRequiredProperty(Property.METHOD) == Method.REQUEST } def "Reply"() { @@ -132,7 +132,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.reply(request) then: 'the calendar object contains method = REPLY' - calendar.getProperties().getRequired(Property.METHOD) == Method.REPLY + calendar.getRequiredProperty(Property.METHOD) == Method.REPLY } def "Add"() { @@ -151,7 +151,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.add(vtodo) then: 'the calendar object contains method = ADD' - calendar.getProperties().getRequired(Property.METHOD) == Method.ADD + calendar.getRequiredProperty(Property.METHOD) == Method.ADD } def "Cancel"() { @@ -168,7 +168,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.cancel(vtodo) then: 'the calendar object contains method = CANCEL' - calendar.getProperties().getRequired(Property.METHOD) == Method.CANCEL + calendar.getRequiredProperty(Property.METHOD) == Method.CANCEL } def "Refresh"() { @@ -183,7 +183,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.refresh(vtodo) then: 'the calendar object contains method = REFRESH' - calendar.getProperties().getRequired(Property.METHOD) == Method.REFRESH + calendar.getRequiredProperty(Property.METHOD) == Method.REFRESH } def "Counter"() { @@ -209,7 +209,7 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.counter(request) then: 'the calendar object contains method = COUNTER' - calendar.getProperties().getRequired(Property.METHOD) == Method.COUNTER + calendar.getRequiredProperty(Property.METHOD) == Method.COUNTER } def "DeclineCounter"() { @@ -233,6 +233,6 @@ class VToDoUserAgentTest extends Specification { def calendar = userAgent.declineCounter(counter) then: 'the calendar object contains method = DECLINECOUNTER' - calendar.getProperties().getRequired(Property.METHOD) == Method.DECLINE_COUNTER + calendar.getRequiredProperty(Property.METHOD) == Method.DECLINE_COUNTER } } diff --git a/src/test/groovy/net/fortuna/ical4j/data/UnfoldingReaderSpec.groovy b/src/test/groovy/net/fortuna/ical4j/data/UnfoldingReaderSpec.groovy index dd9802bad..75e67d8f2 100644 --- a/src/test/groovy/net/fortuna/ical4j/data/UnfoldingReaderSpec.groovy +++ b/src/test/groovy/net/fortuna/ical4j/data/UnfoldingReaderSpec.groovy @@ -33,7 +33,7 @@ class UnfoldingReaderSpec extends Specification { Calendar parsed = new CalendarBuilder().build(new StringReader(calendarString as String)) then: 'the encoded binary is decoded correctly' - def attach = parsed.components.all[0].getProperties().getRequired(Property.ATTACH) + def attach = parsed.components.all[0].getRequiredProperty(Property.ATTACH) def md5 = MessageDigest.getInstance("MD5") md5.digest(attach.binary) == md5.digest(new File('gradle/wrapper/gradle-wrapper.jar').bytes) } diff --git a/src/test/groovy/net/fortuna/ical4j/model/parameter/DisplayTest.groovy b/src/test/groovy/net/fortuna/ical4j/model/parameter/DisplayTest.groovy index 9b1283c88..06aa7dc42 100644 --- a/src/test/groovy/net/fortuna/ical4j/model/parameter/DisplayTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/model/parameter/DisplayTest.groovy @@ -35,6 +35,6 @@ END:VCALENDAR\r Calendar calendar = builder.build(new StringReader(calendarString)) then: 'a valid calendar is realised' - calendar?.components.all[0].properties.all[0].parameters.getRequired('DISPLAY').value == 'BADGE,THUMBNAIL' + calendar?.components.all[0].properties.all[0].getRequiredParameter('DISPLAY').value == 'BADGE,THUMBNAIL' } } diff --git a/src/test/groovy/net/fortuna/ical4j/model/parameter/EmailTest.groovy b/src/test/groovy/net/fortuna/ical4j/model/parameter/EmailTest.groovy index 96bf3b1da..705607712 100644 --- a/src/test/groovy/net/fortuna/ical4j/model/parameter/EmailTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/model/parameter/EmailTest.groovy @@ -35,6 +35,6 @@ END:VCALENDAR Calendar calendar = builder.build(new StringReader(calendarString)) then: 'a valid calendar is realised' - calendar?.components.all[0].properties.all[0].parameters.getRequired('EMAIL').value == 'cyrus@example.com' + calendar?.components.all[0].properties.all[0].getRequiredParameter('EMAIL').value == 'cyrus@example.com' } } diff --git a/src/test/groovy/net/fortuna/ical4j/model/parameter/FeatureTest.groovy b/src/test/groovy/net/fortuna/ical4j/model/parameter/FeatureTest.groovy index 7a9c77809..546905e2a 100644 --- a/src/test/groovy/net/fortuna/ical4j/model/parameter/FeatureTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/model/parameter/FeatureTest.groovy @@ -45,6 +45,6 @@ END:VCALENDAR Calendar calendar = builder.build(new StringReader(calendarString)) then: 'a valid calendar is realised' - calendar?.components.all[0].properties.all[0].parameters.getRequired('FEATURE').value == 'AUDIO' + calendar?.components.all[0].properties.all[0].getRequiredParameter('FEATURE').value == 'AUDIO' } } diff --git a/src/test/groovy/net/fortuna/ical4j/model/parameter/LabelTest.groovy b/src/test/groovy/net/fortuna/ical4j/model/parameter/LabelTest.groovy index 1b6b59264..fe6a5d8c2 100644 --- a/src/test/groovy/net/fortuna/ical4j/model/parameter/LabelTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/model/parameter/LabelTest.groovy @@ -34,6 +34,6 @@ END:VCALENDAR Calendar calendar = builder.build(new StringReader(calendarString)) then: 'a valid calendar is realised' - calendar?.components.all[0].properties.all[0].parameters.getRequired('LABEL').value == 'Web video chat, access code=76543' + calendar?.components.all[0].properties.all[0].getRequiredParameter('LABEL').value == 'Web video chat, access code=76543' } } diff --git a/src/test/java/net/fortuna/ical4j/data/CalendarBuilderCustomRegistryTest.java b/src/test/java/net/fortuna/ical4j/data/CalendarBuilderCustomRegistryTest.java index 549c197df..2b7b7bd81 100644 --- a/src/test/java/net/fortuna/ical4j/data/CalendarBuilderCustomRegistryTest.java +++ b/src/test/java/net/fortuna/ical4j/data/CalendarBuilderCustomRegistryTest.java @@ -40,6 +40,7 @@ import java.io.StringReader; import java.net.URISyntaxException; +import java.util.List; /** * $Id: CalendarBuilderCustomRegistryTest.java [Nov 16, 2009] @@ -92,8 +93,8 @@ public void testCustomParameter() throws Exception { // try to build with a regular builder CalendarBuilder builder = new CalendarBuilder(); Calendar cal = builder.build(new StringReader(VEVENT_WITH_SCHEDULE_STATUS)); - assertTrue(cal.getComponents().getRequired(Component.VEVENT).getProperties().getRequired(Property.ATTENDEE) - .getParameters().getRequired(SCHEDULE_STATUS) instanceof XParameter); + assertTrue(cal.getComponents(Component.VEVENT).get(0).getRequiredProperty(Property.ATTENDEE) + .getRequiredParameter(SCHEDULE_STATUS) instanceof XParameter); // try to build with a custom parameter factory final ParameterFactoryRegistry paramFactory = new ParameterFactoryRegistry(); @@ -119,8 +120,8 @@ public Parameter createParameter(final String value) throws URISyntaxException { cal = builder.build(new StringReader(VEVENT_WITH_SCHEDULE_STATUS)); - VEvent event = cal.getComponents().getRequired(Component.VEVENT); - VEvent eventBis = event.copy(); + List event = cal.getComponents(Component.VEVENT); + VEvent eventBis = event.get(0).copy(); assertEquals(eventBis, event); } } diff --git a/src/test/java/net/fortuna/ical4j/data/CalendarBuilderTimezoneTest.java b/src/test/java/net/fortuna/ical4j/data/CalendarBuilderTimezoneTest.java index df777a7b1..e0a40b909 100755 --- a/src/test/java/net/fortuna/ical4j/data/CalendarBuilderTimezoneTest.java +++ b/src/test/java/net/fortuna/ical4j/data/CalendarBuilderTimezoneTest.java @@ -99,11 +99,11 @@ public void testVTimeZoneAfterVEvent() throws Exception { calendar = builder.build(in); assertNotNull("Calendar is null", calendar); - List comps = calendar.getComponents().get(Component.VEVENT); + List comps = calendar.getComponents(Component.VEVENT); assertTrue("VEVENT not found", comps.size() == 1); VEvent vevent = (VEvent) comps.get(0); - DtStart dtstart = vevent.getProperties().getRequired(Property.DTSTART); + DtStart dtstart = vevent.getRequiredProperty(Property.DTSTART); ZonedDateTime dateTime = (ZonedDateTime) dtstart.getDate(); assertEquals("date value not correct", "20080624T130000", dtstart.getValue()); @@ -175,18 +175,18 @@ public void testTwoDaylights() throws IOException, ParserException, ConstraintVi calendar = builder.build(in); assertNotNull("Calendar is null", calendar); - List comps = calendar.getComponents().get(Component.VEVENT); + List comps = calendar.getComponents(Component.VEVENT); assertEquals("2 VEVENTs not found", 2, comps.size()); VEvent vevent0 = (VEvent) comps.get(0); - DtStart dtstart0 = vevent0.getProperties().getRequired(Property.DTSTART); + DtStart dtstart0 = vevent0.getRequiredProperty(Property.DTSTART); Optional dtstart0TzId = dtstart0.getParameters().getFirst(Parameter.TZID); assertEquals("date value not correct", "20200503T173000", dtstart0.getValue()); assertTrue("timezone not present", dtstart0TzId.isPresent()); assertEquals("timezone not correct", "Europe/Amsterdam", dtstart0TzId.get().getValue()); - DtEnd dtend0 = vevent0.getProperties().getRequired(Property.DTEND); + DtEnd dtend0 = vevent0.getRequiredProperty(Property.DTEND); Optional dtend0TzId = dtend0.getParameters().getFirst(Parameter.TZID); assertEquals("date value not correct", "20200503T200000", dtend0.getValue()); @@ -194,14 +194,14 @@ public void testTwoDaylights() throws IOException, ParserException, ConstraintVi assertEquals("timezone not correct", "Europe/Amsterdam", dtend0TzId.get().getValue()); VEvent vevent1 = (VEvent) comps.get(1); - DtStart dtstart1 = vevent1.getProperties().getRequired(Property.DTSTART); + DtStart dtstart1 = vevent1.getRequiredProperty(Property.DTSTART); Optional dtstart1TzId = dtstart1.getParameters().getFirst(Parameter.TZID); assertEquals("date value not correct", "20191006T190000", dtstart1.getValue()); assertTrue("timezone not present", dtstart1TzId.isPresent()); assertEquals("timezone not correct", "Europe/Amsterdam", dtstart1TzId.get().getValue()); - DtEnd dtend1 = vevent1.getProperties().getRequired(Property.DTEND); + DtEnd dtend1 = vevent1.getRequiredProperty(Property.DTEND); Optional dtend1TzId = dtend1.getParameters().getFirst(Parameter.TZID); assertEquals("date value not correct", "20191006T203000", dtend1.getValue()); diff --git a/src/test/java/net/fortuna/ical4j/data/HCalendarParserTest.java b/src/test/java/net/fortuna/ical4j/data/HCalendarParserTest.java index 686b77a6d..a4322725e 100755 --- a/src/test/java/net/fortuna/ical4j/data/HCalendarParserTest.java +++ b/src/test/java/net/fortuna/ical4j/data/HCalendarParserTest.java @@ -65,7 +65,7 @@ protected void setUp() throws Exception { public void testParseReaderContentHandler() throws IOException, ParserException, ConstraintViolationException { Calendar icsCalendar = Calendars.load(getClass().getResource("/samples/hcalendar/example1.ics")); // remove prod-id which seems to be not handled by hcalendar.. - icsCalendar.getProperties().remove(icsCalendar.getProperties().getRequired(Property.PRODID)); + icsCalendar.getProperties().remove(icsCalendar.getRequiredProperty(Property.PRODID)); CalendarBuilder builder = new CalendarBuilder(new HCalendarParser()); Calendar hcalCalendar = builder.build(getClass().getResourceAsStream("/samples/hcalendar/example1.html")); diff --git a/src/test/java/net/fortuna/ical4j/filter/predicate/PeriodRuleTest.java b/src/test/java/net/fortuna/ical4j/filter/predicate/PeriodRuleTest.java index d79dbde8d..9bca13f10 100644 --- a/src/test/java/net/fortuna/ical4j/filter/predicate/PeriodRuleTest.java +++ b/src/test/java/net/fortuna/ical4j/filter/predicate/PeriodRuleTest.java @@ -187,28 +187,28 @@ public static TestSuite suite() throws FileNotFoundException, IOException, Parse period = new Period<>(day, java.time.Duration.ofDays(1)); LOG.info("period: " + period + " (" + dateFormat.format(period.getStart()) + ")"); filter = new Filter<>(new PeriodRule<>(period)); - suite.addTest(new PeriodRuleTest("testFilteredIsNotEmpty", filter, calendar.getComponents().get(Component.VEVENT))); + suite.addTest(new PeriodRuleTest("testFilteredIsNotEmpty", filter, calendar.getComponents(Component.VEVENT))); // saturday.. day = day.plusDays(1); period = new Period<>(day, java.time.Duration.ofDays(1)); LOG.info("period: " + period + " (" + dateFormat.format(period.getStart()) + ")"); filter = new Filter<>(new PeriodRule<>(period)); - suite.addTest(new PeriodRuleTest("testFilteredIsEmpty", filter, calendar.getComponents().get(Component.VEVENT))); + suite.addTest(new PeriodRuleTest("testFilteredIsEmpty", filter, calendar.getComponents(Component.VEVENT))); // friday.. day = day.plusDays(6); period = new Period<>(day, java.time.Duration.ofDays(1)); LOG.info("period: " + period + " (" + dateFormat.format(period.getStart()) + ")"); filter = new Filter<>(new PeriodRule<>(period)); - suite.addTest(new PeriodRuleTest("testFilteredIsNotEmpty", filter, calendar.getComponents().get(Component.VEVENT))); + suite.addTest(new PeriodRuleTest("testFilteredIsNotEmpty", filter, calendar.getComponents(Component.VEVENT))); // saturday.. day = day.plusDays(1); period = new Period<>(day, java.time.Duration.ofDays(1)); LOG.info("period: " + period + " (" + dateFormat.format(period.getStart()) + ")"); filter = new Filter<>(new PeriodRule<>(period)); - suite.addTest(new PeriodRuleTest("testFilteredIsEmpty", filter, calendar.getComponents().get(Component.VEVENT))); + suite.addTest(new PeriodRuleTest("testFilteredIsEmpty", filter, calendar.getComponents(Component.VEVENT))); return suite; } diff --git a/src/test/java/net/fortuna/ical4j/model/CalendarTest.java b/src/test/java/net/fortuna/ical4j/model/CalendarTest.java index 7079c8bb3..d72ce346e 100644 --- a/src/test/java/net/fortuna/ical4j/model/CalendarTest.java +++ b/src/test/java/net/fortuna/ical4j/model/CalendarTest.java @@ -93,8 +93,8 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException ZonedDateTime end = start.plusYears(1); VEvent week1UserA = new VEvent(start, java.time.Duration.ofHours(8), "Week 1 - User A"); - week1UserA.getProperties().getRequired(Property.DTSTART).add(tzParam); - week1UserA.getProperties().getRequired(Property.DTSTART).add(Value.DATE); + week1UserA.getRequiredProperty(Property.DTSTART).add(tzParam); + week1UserA.getRequiredProperty(Property.DTSTART).add(Value.DATE); WeekDayList monToFri = new WeekDayList(MO, TU, WE, TH, FR); Recur week1UserARecur = new Recur.Builder().frequency(Frequency.WEEKLY) @@ -105,8 +105,8 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException end = end.plusWeeks(1); VEvent week2UserB = new VEvent(start, java.time.Duration.ofHours(8), "Week 2 - User B"); - week2UserB.getProperties().getRequired(Property.DTSTART).add(tzParam); - week2UserB.getProperties().getRequired(Property.DTSTART).add(Value.DATE); + week2UserB.getRequiredProperty(Property.DTSTART).add(tzParam); + week2UserB.getRequiredProperty(Property.DTSTART).add(Value.DATE); Recur week2UserBRecur = new Recur.Builder().frequency(Frequency.WEEKLY) .until(end).interval(3).dayList(monToFri).hourList(new NumberList("9")).build(); @@ -116,7 +116,7 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException end = end.plusWeeks(1); VEvent week3UserC = new VEvent(start, java.time.Duration.ofHours(8), "Week 3 - User C"); - week3UserC.getProperties().getRequired(Property.DTSTART).add(tzParam); + week3UserC.getRequiredProperty(Property.DTSTART).add(tzParam); Recur week3UserCRecur = new Recur.Builder().frequency(Frequency.WEEKLY) .until(end).interval(3).dayList(monToFri).hourList(new NumberList("9")).build(); @@ -133,7 +133,7 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException end = start.plusYears(1); week1UserA = new VEvent(start, java.time.Duration.ofHours(8), "Week 1 - User A"); - week1UserA.getProperties().getRequired(Property.DTSTART).add(tzParam); + week1UserA.getRequiredProperty(Property.DTSTART).add(tzParam); week1UserARecur = new Recur.Builder().frequency(Frequency.WEEKLY) .until(end).interval(3).dayList(monToFri).hourList(new NumberList("9")).build(); @@ -143,7 +143,7 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException end = end.plusWeeks(1); week2UserB = new VEvent(start, java.time.Duration.ofHours(8), "Week 2 - User B"); - week2UserB.getProperties().getRequired(Property.DTSTART).add(tzParam); + week2UserB.getRequiredProperty(Property.DTSTART).add(tzParam); week2UserBRecur = new Recur.Builder().frequency(Frequency.WEEKLY) .until(end).interval(3).dayList(monToFri).hourList(new NumberList("9")).build(); @@ -153,7 +153,7 @@ public void testValid2() throws URISyntaxException, ConstraintViolationException end = end.plusWeeks(1); week3UserC = new VEvent(start, java.time.Duration.ofHours(8), "Week 3 - User C"); - week3UserC.getProperties().getRequired(Property.DTSTART).getParameters().add(tzParam); + week3UserC.getRequiredProperty(Property.DTSTART).getParameters().add(tzParam); week3UserCRecur = new Recur.Builder().frequency(Frequency.WEEKLY) .until(end).interval(3).dayList(monToFri).hourList(new NumberList("9")).build(); diff --git a/src/test/java/net/fortuna/ical4j/model/IndexedPropertyListTest.java b/src/test/java/net/fortuna/ical4j/model/IndexedPropertyListTest.java index 61f455bed..2f513720b 100644 --- a/src/test/java/net/fortuna/ical4j/model/IndexedPropertyListTest.java +++ b/src/test/java/net/fortuna/ical4j/model/IndexedPropertyListTest.java @@ -77,7 +77,7 @@ protected final void tearDown() throws Exception { */ public void testIndexing() { // a VEvent for more interesting data.. - Component component = calendar.getComponents().get(Component.VEVENT).iterator().next(); + Component component = calendar.getComponents(Component.VEVENT).iterator().next(); IndexedPropertyList list = new IndexedPropertyList(component.getProperties().getAll(), Parameter.CUTYPE); LOG.info(list.getProperties(CuType.INDIVIDUAL.getValue()).size() + " individual attendees."); diff --git a/src/test/java/net/fortuna/ical4j/model/TimeZoneTest.java b/src/test/java/net/fortuna/ical4j/model/TimeZoneTest.java index 97015d23f..a17aee189 100644 --- a/src/test/java/net/fortuna/ical4j/model/TimeZoneTest.java +++ b/src/test/java/net/fortuna/ical4j/model/TimeZoneTest.java @@ -44,9 +44,8 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Calendar; -import java.util.Collections; import java.util.Date; -import java.util.GregorianCalendar; +import java.util.*; /** * $Id$ @@ -180,8 +179,8 @@ public TimeZoneTest(String testMethod, String vtimezoneDef, String zuluDateTimeS String expectedLocalDateTimeStr) throws Exception { super(testMethod); net.fortuna.ical4j.model.Calendar cal = new CalendarBuilder().build(new StringReader(vtimezoneDef)); - VTimeZone vtz = cal.getComponents().getRequired(VTimeZone.VTIMEZONE); - this.timezone = new TimeZone(vtz); + List vtz = cal.getComponents(VTimeZone.VTIMEZONE); + this.timezone = new TimeZone(vtz.get(0)); this.zuluDateTimeStr = zuluDateTimeStr; this.expectedLocalDateTimeStr = expectedLocalDateTimeStr; } diff --git a/src/test/java/net/fortuna/ical4j/model/component/VAvailabilityTestCase.java b/src/test/java/net/fortuna/ical4j/model/component/VAvailabilityTestCase.java index 1cacab661..ce2a2fe41 100644 --- a/src/test/java/net/fortuna/ical4j/model/component/VAvailabilityTestCase.java +++ b/src/test/java/net/fortuna/ical4j/model/component/VAvailabilityTestCase.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.util.List; /** @@ -54,9 +55,9 @@ public void testVAvailability() throws ParserException, IOException, ConstraintV String availability = getVAvailabilityICal(); Reader reader = new StringReader(availability); Calendar calendar = calendarBuilder.build(reader); - VAvailability availabilityComponent = calendar.getComponents().getRequired(Component.VAVAILABILITY); - Assert.assertNotNull(availabilityComponent); - Assert.assertFalse(availabilityComponent.getAvailable().getAll().isEmpty()); + List availabilityComponent = calendar.getComponents(Component.VAVAILABILITY); + Assert.assertFalse(availabilityComponent.isEmpty()); + Assert.assertFalse(availabilityComponent.get(0).getAvailable().getAll().isEmpty()); String iCalString = calendar.toString(); Assert.assertTrue(iCalString.contains("BEGIN:AVAILABLE")); Assert.assertEquals(iCalString.trim(), availability); diff --git a/src/test/java/net/fortuna/ical4j/model/component/VEventTest.java b/src/test/java/net/fortuna/ical4j/model/component/VEventTest.java index 4868e97fb..a9093e55c 100644 --- a/src/test/java/net/fortuna/ical4j/model/component/VEventTest.java +++ b/src/test/java/net/fortuna/ical4j/model/component/VEventTest.java @@ -201,10 +201,10 @@ public final void test2() throws ConstraintViolationException { VEvent christmas = new VEvent(christmasDay, "Christmas Day"); // initialise as an all-day event.. - christmas.getProperties().getRequired(Property.DTSTART).add(Value.DATE); + christmas.getRequiredProperty(Property.DTSTART).add(Value.DATE); // add timezone information.. - christmas.getProperties().getRequired(Property.DTSTART).add(tzParam); + christmas.getRequiredProperty(Property.DTSTART).add(tzParam); log.info(christmas.toString()); } @@ -216,7 +216,7 @@ public final void test3() throws ConstraintViolationException { VEvent meeting = new VEvent(tomorrow, java.time.Duration.ofHours(1), "Progress Meeting"); // add timezone information.. - meeting.getProperties().getRequired(Property.DTSTART).add(tzParam); + meeting.getRequiredProperty(Property.DTSTART).add(tzParam); log.info(meeting.toString()); } @@ -381,12 +381,12 @@ public final void testGetConsumedTime3() throws Exception { net.fortuna.ical4j.model.Calendar calendar = loadCalendar(resource); - VEvent vev = calendar.getComponents().getRequired(Component.VEVENT); + List vev = calendar.getComponents(Component.VEVENT); - LocalDate start = (LocalDate) vev.getStartDate().get().getDate(); + LocalDate start = (LocalDate) vev.get(0).getStartDate().get().getDate(); LocalDate latest = LocalDate.now().plusYears(1); - List> pl = vev.getConsumedTime(new Period<>(start, latest)); + List> pl = vev.get(0).getConsumedTime(new Period<>(start, latest)); assertTrue(!pl.isEmpty()); } @@ -473,12 +473,12 @@ public void testGetConsumedTimeWithExDate2() throws IOException, ParserException InputStream in = getClass().getResourceAsStream("/samples/valid/friday13.ics"); net.fortuna.ical4j.model.Calendar calendar = new CalendarBuilder().build(in); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); + List event = calendar.getComponents(Component.VEVENT); ZonedDateTime start = ZonedDateTime.now().withYear(1997).withMonth(8).withDayOfMonth(2); ZonedDateTime end = start.withDayOfMonth(4); - List> periods = event.getConsumedTime(new Period<>(start, end)); + List> periods = event.get(0).getConsumedTime(new Period<>(start, end)); assertTrue(periods.isEmpty()); } @@ -640,7 +640,7 @@ public static TestSuite suite() throws ValidationException, IOException, ParserE // test 1.. event = event.copy(); startParams = new ParameterList(Collections.singletonList(Value.DATE)); - newstart = new DtStart<>(startParams, event.getProperties().getRequired(Property.DTSTART).getValue()); + newstart = new DtStart<>(startParams, event.getRequiredProperty(Property.DTSTART).getValue()); event.replace(newstart); suite.addTest(new VEventTest<>("testValidationException", event)); @@ -654,11 +654,11 @@ public static TestSuite suite() throws ValidationException, IOException, ParserE // test 2.. event = event.copy(); startParams = new ParameterList(Collections.singletonList(Value.DATE_TIME)); - start = new DtStart<>(startParams, event.getProperties().getRequired(Property.DTSTART).getValue()); + start = new DtStart<>(startParams, event.getRequiredProperty(Property.DTSTART).getValue()); event.replace(start); endParams = new ParameterList(Collections.singletonList(Value.DATE_TIME)); - end = new DtEnd<>(endParams, event.getProperties().getRequired(Property.DTEND).getValue()); + end = new DtEnd<>(endParams, event.getRequiredProperty(Property.DTEND).getValue()); event.replace(end); suite.addTest(new VEventTest<>("testValidationException", event)); @@ -695,12 +695,12 @@ public static TestSuite suite() throws ValidationException, IOException, ParserE for (URL testFile : testFiles) { log.info("Sample [" + testFile + "]"); net.fortuna.ical4j.model.Calendar calendar = Calendars.load(testFile); - if (Method.PUBLISH.equals(calendar.getProperties().getRequired(Property.METHOD))) { - calendar.getComponents().get(Component.VEVENT).forEach(calendarComponent -> { + if (Method.PUBLISH.equals(calendar.getRequiredProperty(Property.METHOD))) { + calendar.getComponents(Component.VEVENT).forEach(calendarComponent -> { suite.addTest(new VEventTest<>("testPublishValidation", (VEvent) calendarComponent)); }); - } else if (Method.REQUEST.equals(calendar.getProperties().getRequired(Property.METHOD))) { - calendar.getComponents().get(Component.VEVENT).forEach(calendarComponent -> { + } else if (Method.REQUEST.equals(calendar.getRequiredProperty(Property.METHOD))) { + calendar.getComponents(Component.VEVENT).forEach(calendarComponent -> { suite.addTest(new VEventTest<>("testRequestValidation", (VEvent) calendarComponent)); }); } diff --git a/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java b/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java index e9b63cae9..312917cfa 100644 --- a/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java +++ b/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java @@ -226,7 +226,7 @@ public final void testVFreeBusyComponentList3() throws ConstraintViolationExcept // VEvent event = new VEvent(startDate, cal.getTime(), "Progress // Meeting"); // add timezone information.. - event.getProperties().getRequired(Property.DTSTART).add(tzParam); + event.getRequiredProperty(Property.DTSTART).add(tzParam); // add recurrence.. Recur recur = new Recur.Builder().frequency(Frequency.YEARLY).count(20) diff --git a/src/test/java/net/fortuna/ical4j/model/property/AttachTest.java b/src/test/java/net/fortuna/ical4j/model/property/AttachTest.java index 9e1b62332..df9a50c63 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/AttachTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/AttachTest.java @@ -48,6 +48,7 @@ import java.time.LocalDate; import java.util.Arrays; import java.util.Collections; +import java.util.List; /** * $Id$ @@ -114,9 +115,9 @@ public void testAttachParameterListString() throws IOException, URISyntaxExcepti CalendarBuilder builder = new CalendarBuilder(); Calendar cout = builder.build(new StringReader(sw.toString())); - VEvent eout = cout.getComponents().getRequired(Component.VEVENT); + List eout = cout.getComponents(Component.VEVENT); - Attach aout = eout.getProperties().getRequired(Property.ATTACH); + Attach aout = eout.get(0).getRequiredProperty(Property.ATTACH); assertNotNull(aout); assertEquals(attach, aout); diff --git a/src/test/java/net/fortuna/ical4j/model/property/AttendeeTest.java b/src/test/java/net/fortuna/ical4j/model/property/AttendeeTest.java index 9a740eba7..5d8c78394 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/AttendeeTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/AttendeeTest.java @@ -106,7 +106,7 @@ public void testRelaxedParsing() throws IOException, ParserException, Constraint CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); Calendar calendar = Calendars.load(getClass().getResource("/samples/invalid/groupwise.ics")); - Attendee attendee = calendar.getComponents().getRequired(Component.VEVENT).getProperties().getRequired(Property.ATTENDEE); + Attendee attendee = calendar.getComponents(Component.VEVENT).get(0).getRequiredProperty(Property.ATTENDEE); assertNotNull(attendee.getCalAddress()); } } diff --git a/src/test/java/net/fortuna/ical4j/model/property/CategoriesTest.java b/src/test/java/net/fortuna/ical4j/model/property/CategoriesTest.java index b0096043e..78d1540e9 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/CategoriesTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/CategoriesTest.java @@ -108,8 +108,8 @@ public void testCommaEscaping() throws ValidationException, IOException, calendar = builder.build(new StringReader(tempOut.getBuffer() .toString())); - List categories = calendar.getComponents().getRequired(Component.VEVENT) - .getProperties().get(Property.CATEGORIES); + List categories = calendar.getComponents(Component.VEVENT) + .get(0).getProperties(Property.CATEGORIES); assertEquals(cat1, categories.get(0)); assertEquals(cat2, categories.get(1)); @@ -141,7 +141,7 @@ public static TestSuite suite() throws IOException, ValidationException, // Test escaping of categories string representation.. Calendar calendar = Calendars.load(CategoriesTest.class.getResource("/samples/valid/categories.ics")); - Categories orig = calendar.getComponents().getRequired(Component.VEVENT).getProperties().getRequired(Property.CATEGORIES); + Categories orig = calendar.getComponents(Component.VEVENT).get(0).getRequiredProperty(Property.CATEGORIES); StringWriter tempOut = new StringWriter(); CalendarOutputter cout = new CalendarOutputter(); @@ -151,7 +151,7 @@ public static TestSuite suite() throws IOException, ValidationException, calendar = builder.build(new StringReader(tempOut.getBuffer() .toString())); - Categories copy = calendar.getComponents().getRequired(Component.VEVENT).getProperties().getRequired(Property.CATEGORIES); + Categories copy = calendar.getComponents(Component.VEVENT).get(0).getRequiredProperty(Property.CATEGORIES); assertEquals(orig, copy); suite.addTest(new CategoriesTest(copy, orig.getValue())); diff --git a/src/test/java/net/fortuna/ical4j/model/property/DescriptionTest.java b/src/test/java/net/fortuna/ical4j/model/property/DescriptionTest.java index 986b11e21..f7f3f44b8 100755 --- a/src/test/java/net/fortuna/ical4j/model/property/DescriptionTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/DescriptionTest.java @@ -38,6 +38,7 @@ import net.fortuna.ical4j.util.Calendars; import java.io.IOException; +import java.util.List; /** * Created on 21/08/2007 @@ -63,8 +64,8 @@ public static TestSuite suite() throws IOException, ParserException, ConstraintV TestSuite suite = new TestSuite(); // Test correct parsing of text with tabs. Calendar calendar = Calendars.load(DescriptionTest.class.getResource("/samples/valid/mansour.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); - Description description = event.getProperties().getRequired(Property.DESCRIPTION); + List event = calendar.getComponents(Component.VEVENT); + Description description = event.get(0).getRequiredProperty(Property.DESCRIPTION); suite.addTest(new DescriptionTest(description, "Test\t\ttabs")); return suite; } diff --git a/src/test/java/net/fortuna/ical4j/model/property/ExDateTest.java b/src/test/java/net/fortuna/ical4j/model/property/ExDateTest.java index da88c959c..e4621e232 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/ExDateTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/ExDateTest.java @@ -83,8 +83,8 @@ public void testTimeZones() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); - List exdates = event.getProperties().get(Property.EXDATE); + List event = calendar.getComponents(Component.VEVENT); + List exdates = event.get(0).getProperties(Property.EXDATE); for (Property exDate : exdates) { assertTrue("This EXDATE should have a timezone", exDate.getParameters().getFirst(Parameter.TZID).isPresent()); } @@ -94,15 +94,15 @@ public void testDstOnlyVTimeZones() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar ical = builder.build(getClass().getResourceAsStream("/samples/valid/dst-only-vtimezone.ics")); - VTimeZone vTZ = ical.getComponents().getRequired(VTimeZone.VTIMEZONE); + List vTZ = ical.getComponents(VTimeZone.VTIMEZONE); - String id = vTZ.getProperties().getRequired(Property.TZID).getValue(); + String id = vTZ.get(0).getRequiredProperty(Property.TZID).getValue(); assertEquals("Europe/Berlin", id); - assertEquals(vTZ.getObservances().getAll().get(0), - vTZ.getApplicableObservance(TemporalAdapter.parse("20180403T000000Z").getTemporal())); + assertEquals(vTZ.get(0).getObservances().getAll().get(0), + vTZ.get(0).getApplicableObservance(TemporalAdapter.parse("20180403T000000Z").getTemporal())); - VEvent vEvent = ical.getComponents().getRequired(VEvent.VEVENT); - DtStart start = vEvent.getProperties().getRequired("DTSTART"); + List vEvent = ical.getComponents(VEvent.VEVENT); + DtStart start = vEvent.get(0).getRequiredProperty("DTSTART"); assertEquals(1522738800000L, Instant.from(start.getDate()).toEpochMilli()); } @@ -110,8 +110,8 @@ public void testShouldPreserveUtcTimezoneForExDate() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE-IN-UTC.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); - List exdates = event.getProperties().get(Property.EXDATE); + List event = calendar.getComponents(Component.VEVENT); + List exdates = event.get(0).getProperties(Property.EXDATE); for (Property exDate : exdates) { for (Instant dateEx : ((ExDate) exDate).getDates()) { assertNotNull(dateEx); diff --git a/src/test/java/net/fortuna/ical4j/model/property/LocationTest.java b/src/test/java/net/fortuna/ical4j/model/property/LocationTest.java index c32bb8ced..80d2daf79 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/LocationTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/LocationTest.java @@ -38,6 +38,7 @@ import net.fortuna.ical4j.util.Calendars; import java.io.IOException; +import java.util.List; /** * $Id$ @@ -72,9 +73,9 @@ public LocationTest(String testMethod, Location property) { */ public void testQuotedText() throws IOException, ParserException, ConstraintViolationException { Calendar calendar = Calendars.load(getClass().getResource("/samples/valid/mansour.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); + List event = calendar.getComponents(Component.VEVENT); assertEquals("At \"The Terrace\" Complex > Melbourne \"\\,", - event.getProperties().getRequired(Property.LOCATION).getValue()); + event.get(0).getRequiredProperty(Property.LOCATION).getValue()); } /** @@ -86,8 +87,8 @@ public static TestSuite suite() throws IOException, ParserException, ConstraintV TestSuite suite = new TestSuite(); //testQuotedText.. Calendar calendar = Calendars.load(LocationTest.class.getResource("/samples/valid/mansour.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); - Location location = event.getProperties().getRequired(Property.LOCATION); + List event = calendar.getComponents(Component.VEVENT); + Location location = event.get(0).getRequiredProperty(Property.LOCATION); suite.addTest(new LocationTest(location, "At \"The Terrace\" Complex > Melbourne \"\\,")); return suite; } diff --git a/src/test/java/net/fortuna/ical4j/model/property/SummaryTest.java b/src/test/java/net/fortuna/ical4j/model/property/SummaryTest.java index 8d5934123..0e43e14bb 100644 --- a/src/test/java/net/fortuna/ical4j/model/property/SummaryTest.java +++ b/src/test/java/net/fortuna/ical4j/model/property/SummaryTest.java @@ -38,6 +38,7 @@ import net.fortuna.ical4j.util.Calendars; import java.io.IOException; +import java.util.List; /** * $Id$ @@ -74,8 +75,8 @@ public static TestSuite suite() throws IOException, ParserException, ConstraintV TestSuite suite = new TestSuite(); // Test correct parsing of quoted text.. Calendar calendar = Calendars.load(SummaryTest.class.getResource("/samples/valid/mansour.ics")); - VEvent event = calendar.getComponents().getRequired(Component.VEVENT); - Summary summary = event.getProperties().getRequired(Property.SUMMARY); + List event = calendar.getComponents(Component.VEVENT); + Summary summary = event.get(0).getRequiredProperty(Property.SUMMARY); suite.addTest(new SummaryTest(summary, "A colon with spaces on either side : like that")); suite.addTest(new SummaryTest("testValidation", summary));