Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Aug 1, 2021
1 parent 2d3c430 commit 9772ce8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/Calendar.java
Expand Up @@ -115,7 +115,7 @@
*
* @author Ben Fortuna
*/
public class Calendar implements Serializable {
public class Calendar implements Serializable, PropertyContainer {

private static final long serialVersionUID = -1654118204678581940L;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/Component.java
Expand Up @@ -54,7 +54,7 @@
*
* @author Ben Fortuna
*/
public abstract class Component implements Serializable {
public abstract class Component implements Serializable, PropertyContainer {

private static final long serialVersionUID = 4943193483665822201L;

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/fortuna/ical4j/model/PropertyContainer.java
@@ -0,0 +1,10 @@
package net.fortuna.ical4j.model;

public interface PropertyContainer {

PropertyList<Property> getProperties();

<T extends Property> PropertyList<T> getProperties(final String name);

<T extends Property> T getProperty(final String name);
}
Expand Up @@ -3,6 +3,7 @@
import java.time.Duration;
import java.time.Period;
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalUnit;
import java.util.Comparator;

public class TemporalAmountComparator implements Comparator<TemporalAmount> {
Expand All @@ -11,8 +12,8 @@ public int compare(TemporalAmount o1, TemporalAmount o2) {
int result = 0;
if (!o1.getClass().equals(o2.getClass())) {
// throw new UnsupportedOperationException("Unable to compare different Temporal types");
boolean o1datebased = o1.getUnits().stream().anyMatch(u -> u.isDateBased());
boolean o2datebased = o2.getUnits().stream().anyMatch(u -> u.isDateBased());
boolean o1datebased = o1.getUnits().stream().anyMatch(TemporalUnit::isDateBased);
boolean o2datebased = o2.getUnits().stream().anyMatch(TemporalUnit::isDateBased);
if (o1datebased != o2datebased) {
if (o1datebased) {
result = Integer.MAX_VALUE;
Expand Down

0 comments on commit 9772ce8

Please sign in to comment.