Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a32216e
commit 4c20a26
Showing
11 changed files
with
353 additions
and
119 deletions.
There are no files selected for viewing
36 changes: 30 additions & 6 deletions
36
src/main/java/net/fortuna/ical4j/filter/predicate/DateInRangeRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 39 additions & 29 deletions
68
src/main/java/net/fortuna/ical4j/filter/predicate/ParameterEqualToRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,56 @@ | ||
/* | ||
* Copyright (c) 2012-2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. | ||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. | ||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. | ||
* Vestibulum commodo. Ut rhoncus gravida arcu. | ||
/** | ||
* Copyright (c) 2004-2021, Ben Fortuna | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* o Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* o Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* o Neither the name of Ben Fortuna nor the names of any other contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.fortuna.ical4j.filter.predicate; | ||
|
||
import net.fortuna.ical4j.model.Parameter; | ||
import net.fortuna.ical4j.model.ParameterList; | ||
import net.fortuna.ical4j.model.Property; | ||
|
||
import java.util.Arrays; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* $Id$ | ||
* | ||
* Created on 5/02/2006 | ||
* | ||
* A rule that matches any component containing the specified property. Note that this rule ignores any parameters | ||
* matching only on the value of the property. | ||
* @author Ben Fortuna | ||
* Test for one or more parameters matching the specification. | ||
*/ | ||
public class ParameterEqualToRule<T extends Property> implements Predicate<T> { | ||
|
||
private final String parameterName; | ||
public class ParameterEqualToRule<T extends Parameter> implements Predicate<Property> { | ||
|
||
private final Object value; | ||
private final T[] specification; | ||
|
||
public ParameterEqualToRule(String parameterName, Object value) { | ||
this.parameterName = parameterName; | ||
this.value = value; | ||
@SafeVarargs | ||
public ParameterEqualToRule(T... specification) { | ||
this.specification = specification; | ||
} | ||
|
||
@Override | ||
public final boolean test(final Property property) { | ||
final ParameterList parameters = property.getParameters(parameterName); | ||
for (final Parameter p : parameters) { | ||
if (value.equals(p.getValue())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
public boolean test(Property t) { | ||
return Arrays.stream(specification).allMatch(p -> t.getParameters().contains(p)); | ||
} | ||
} |
52 changes: 36 additions & 16 deletions
52
src/main/java/net/fortuna/ical4j/filter/predicate/ParameterExistsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
/* | ||
* Copyright (c) 2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. | ||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. | ||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. | ||
* Vestibulum commodo. Ut rhoncus gravida arcu. | ||
/** | ||
* Copyright (c) 2004-2021, Ben Fortuna | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* o Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* o Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* o Neither the name of Ben Fortuna nor the names of any other contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package net.fortuna.ical4j.filter.predicate; | ||
|
||
import net.fortuna.ical4j.model.Property; | ||
|
||
import java.util.Arrays; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Test for a parameter matching the provided name. | ||
* Test for one or more parameters matching the specification. | ||
*/ | ||
public class ParameterExistsRule implements Predicate<Property> { | ||
|
||
private final String parameterName; | ||
private final String[] specification; | ||
|
||
public ParameterExistsRule(String parameterName) { | ||
this.parameterName = parameterName; | ||
public ParameterExistsRule(String... specification) { | ||
this.specification = specification; | ||
} | ||
|
||
@Override | ||
public boolean test(Property t) { | ||
String[] param = parameterName.split(":"); | ||
if (param.length > 1) { | ||
return new ParameterEqualToRule<>(param[0], param[1]).test(t); | ||
} | ||
return !t.getParameters(parameterName).isEmpty(); | ||
return Arrays.stream(specification).noneMatch(p -> t.getParameters(p).isEmpty()); | ||
} | ||
} |
36 changes: 30 additions & 6 deletions
36
src/main/java/net/fortuna/ical4j/filter/predicate/PeriodRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 30 additions & 7 deletions
37
src/main/java/net/fortuna/ical4j/filter/predicate/PropertyContainsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.