8000 Merge pull request #628 from ical4j/develop · ical4j/ical4j@b51b059 · GitHub
[go: up one dir, main page]

Skip to content

Commit b51b059

Browse files
authored
Merge pull request #628 from ical4j/develop
Prepare release
2 parents 55ba288 + 445fb55 commit b51b059

File tree

12 files changed

+190
-29
lines changed

12 files changed

+190
-29
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CHANGELOG_START_TAG=ical4j-3.2.9
1+
CHANGELOG_START_TAG=ical4j-3.2.10
22
CHANGELOG_END_TAG=HEAD
33

44
GRADLE_VERSION=7.4.2

build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ dependencies {
4545
api "org.slf4j:slf4j-api:$slf4jVersion",
4646
"commons-codec:commons-codec:$commonsCodecVersion",
4747
"org.apache.commons:commons-lang3:$commonsLangVersion",
48-
"org.apache.commons:commons-collections4:$commonsCollectionsVersion",
49-
"commons-validator:commons-validator:$commonsValidatorVersion"
48+
"org.apache.commons:commons-collections4:$commonsCollectionsVersion"
49+
50+
api ("commons-validator:commons-validator:$commonsValidatorVersion") {
51+
exclude group: 'commons-collections', module: 'commons-collections'
52+
}
5053

5154
// optional timezone caching..
5255
implementation 'javax.cache:cache-api:1.1.1', optional

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jacoco_htmlReport = false
2121
org.gradle.caching = true
2222
org.gradle.vfs.watch = true
2323

24-
revApiOldVersion = 3.2.9
24+
revApiOldVersion = 3.2.10

src/main/java/net/fortuna/ical4j/filter/AbstractFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.io.IOException;
4545
import java.net.URISyntaxException;
4646
import java.text.ParseException;
47+
import java.util.Collection;
4748
import java.util.List;
4849
import java.util.function.Supplier;
4950
import java.util.stream.Collectors;
@@ -122,7 +123,7 @@ protected Property property(BinaryExpression expression) {
122123
*/
123124
protected List<Comparable<Property>> properties(BinaryExpression expression) {
124125
FilterTarget operand = target(expression);
125-
List<String> literal = literal(expression);
126+
Collection<String> literal = literal(expression);
126127
return literal.stream().map(l -> property(operand, l)).collect(Collectors.toList());
127128
}
128129

@@ -198,7 +199,7 @@ protected Parameter parameter(BinaryExpression expression) {
198199
protected List<Comparable<Parameter>> parameters(BinaryExpression expression) {
199200
// only applicable for operand expressions..
200201
FilterTarget specification = target(expression);
201-
List<String> literal = literal(expression);
202+
Collection<String> literal = literal(expression);
202203
return literal.stream().map(l -> parameter(specification.getName(), l)).collect(Collectors.toList());
203204
}
204205

src/main/java/net/fortuna/ical4j/model/ComponentGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ComponentGroup(ComponentList<T> components, Uid uid, RecurrenceId recurre
5757
* @return
5858
*/
5959
public ComponentList<T> getRevisions() {
60-
return new ComponentList<T>(components.stream().filter(componentPredicate).collect(Collectors.toList()));
60+
return new ComponentList<>(components.stream().filter(componentPredicate).collect(Collectors.toList()));
6161
}
6262

6363
/**
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2023, Ben Fortuna
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* o Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* o Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* o Neither the name of Ben Fortuna nor the names of any other contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*
32+
*/
33+
34+
package net.fortuna.ical4j.model;
35+
36+
import net.fortuna.ical4j.model.component.CalendarComponent;
37+
import net.fortuna.ical4j.model.property.RecurrenceId;
38+
39+
import java.io.IOException;
40+
import java.net.URISyntaxException;
41+
import java.text.ParseException;
42+
import java.util.ArrayList;
43+
import java.util.List;
10000
44+
45+
public interface RecurrenceSupport<T extends CalendarComponent> extends PropertyContainer {
46+
47+
<C extends Component> C copy() throws ParseException, IOException, URISyntaxException;
48+
49+
/**
50+
* Calculates the recurrence set for this component using the specified period.
51+
* The recurrence set is derived from a combination of the component start date,
52+
* recurrence rules and dates, and exception rules and dates. Note that component
53+
* transparency and anniversary-style dates do not affect the resulting
54+
* intersection.
55+
* <p>If an explicit DURATION is not specified, the effective duration of each
56+
* returned period is derived from the DTSTART and DTEND or DUE properties.
57+
* If the component has no DURATION, DTEND or DUE, the effective duration is set
58+
* to PT0S</p>
59+
*
60+
* @param period a range to calculate recurrences for
61+
* @return a list of periods
62+
*/
63+
PeriodList calculateRecurrenceSet(final Period period);
64+
65+
default List<T> getOccurrences(Period period) throws ParseException, IOException, URISyntaxException {
66+
List<T> occurrences = new ArrayList<>();
67+
68+
PeriodList periods = RecurrenceSupport.this.calculateRecurrenceSet(period);
69+
for (Period p : periods) {
70+
final T occurrence = this.copy();
71+
occurrence.getProperties().add(new RecurrenceId(p.getStart()));
72+
occurrences.add(occurrence);
73+
}
74+
75+
return occurrences;
76+
}
77+
}

src/main/java/net/fortuna/ical4j/model/component/VEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
*
191191
* @author Ben Fortuna
192192
*/
193-
public class VEvent extends CalendarComponent implements ComponentContainer<Component> {
193+
public class VEvent extends CalendarComponent implements ComponentContainer<Component>, RecurrenceSupport<VEvent> {
194194

195195
private static final long serialVersionUID = 2547948989200697335L;
196196

@@ -451,7 +451,9 @@ public final PeriodList getConsumedTime(final Date rangeStart,
451451
* @throws IOException where an error occurs reading data
452452
* @throws URISyntaxException where an invalid URI is encountered
453453
* @throws ParseException where an error occurs parsing data
454+
* @deprecated use {@link RecurrenceSupport#getOccurrences(Period)}
454455
*/
456+
@Deprecated
455457
public final VEvent getOccurrence(final Date date) throws IOException,
456458
URISyntaxException, ParseException {
457459

src/main/java/net/fortuna/ical4j/model/component/VJournal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
*
101101
* @author Ben Fortuna
102102
*/
103-
public class VJournal extends CalendarComponent implements ComponentContainer<Component> {
103+
public class VJournal extends CalendarComponent implements ComponentContainer<Component>, RecurrenceSupport<VJournal> {
104104

105105
private static final long serialVersionUID = -7635140949183238830L;
106106

src/main/java/net/fortuna/ical4j/model/component/VToDo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
*
113113
* @author Ben Fortuna
114114
*/
115-
public class VToDo extends CalendarComponent implements ComponentContainer<Component> {
115+
public class VToDo extends CalendarComponent implements ComponentContainer<Component>, RecurrenceSupport<VToDo> {
116116

117117
private static final long serialVersionUID = -269658210065896668L;
118118

src/test/groovy/net/fortuna/ical4j/filter/ComponentFilterTest.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package net.fortuna.ical4j.filter
22

33
import net.fortuna.ical4j.model.ContentBuilder
4+
import net.fortuna.ical4j.model.Property
45
import net.fortuna.ical4j.model.property.Attendee
56
import net.fortuna.ical4j.model.property.Organizer
7+
import net.fortuna.ical4j.model.property.Summary
68
import spock.lang.Ignore
79
import spock.lang.Shared
810
import spock.lang.Specification
@@ -18,10 +20,14 @@ class ComponentFilterTest extends Specification {
1820
@Shared
1921
Attendee attendee
2022

23+
@Shared
24+
Summary summary
25+
2126
def setupSpec() {
2227
builder = new ContentBuilder()
2328
organiser = builder.organizer('Mailto:B@example.com')
2429
attendee = builder.attendee('Mailto:A@example.com')
30+
summary = builder.summary('Test')
2531
}
2632

2733
def 'test filter expression equals'() {
@@ -149,4 +155,19 @@ class ComponentFilterTest extends Specification {
149155
'request-status not exists' | true
150156
'sequence > 1' | true
151157
}
158+
159+
def 'test filter expressions with sets'() {
160+
given: 'a filter expression using sets'
161+
def filter = FilterExpression.in(Property.SUMMARY, ['Test'] as Set)
162+
163+
and: 'an event'
164+
def event = builder.vevent {
165+
organizer(organiser)
166+
attendee(attendee)
167+
summary(summary)
168+
}
169+
170+
expect: 'filter matches the event'
171+
new ComponentFilter().predicate(filter).test(event)
172+
}
152173
}

0 commit comments

Comments
 (0)
0