Comments (3)
Let me know if you think there are advantages for your suggestion over this one.
Gladly!
This basically indicates there is no correlation between the period and the recurrence set, as the temporal type is derived from the type used in
DTSTART
property.
That makes sense to me.
Generally, I think a library should use the type system to specify what it guarantees. The user of the library can make additional assumptions, and the mechanism to encode those is casts. From that perspective, I think
public final Set<Period<Temporal>> calculateRecurrenceSet(Period<? extends Temporal> period)
would be slightly better. In
Set<Period<LocalDate>> result = calculateRecurrenceSet(period);
LocalDate date = result.iterator().next().getStart()
, when passing in events with different types for the DTSTART
property, it would be surprising to me to get a ClassCastException on the second line. With my proposed signature, indeed this code becomes either
Set<Period<LocalDate>> result = (Set<Period<LocalDate>>) calculateRecurrenceSet(period);
LocalDate date = result.iterator().next().getStart()
or
Set<Period<Temporal>> result = calculateRecurrenceSet(period);
LocalDate date = (LocalDate) result.iterator().next().getStart()
While this is more verbose, I like how the cast makes it explicit that I'm responsible for this assumption (justified by the knowledge of the DTSTART
property).
Anyway, I don't feel particularly strongly about this, and I'm happy with the library as it is, but since you asked these are my 2ct :)
from ical4j.
Thanks for the feedback, apologies for late response.
This has been fixed in a recent version, although the fix is slightly different to your suggestion:
public final <T extends Temporal> Set<Period<T>> calculateRecurrenceSet(Period<? extends Temporal> period)
This basically indicates there is no correlation between the period and the recurrence set, as the temporal type is derived from the type used in DTSTART
property.
The difference is that the caller can use their knowledge of the DTSTART
property to assume the correct type, e.g:
Set<Period<LocalDate>> result = calculateRecurrenceSet(period);
Let me know if you think there are advantages for your suggestion over this one.
from ical4j.
Good points, although I think the explicit cast of the entire set doesn't work (I get following error):
Inconvertible types; cannot cast 'java.util.Set<net.fortuna.ical4j.model.Period<java.time.temporal.Temporal>>' to 'java.util.Set<net.fortuna.ical4j.model.Period<java.time.LocalDate>>'
Still, I might change it anyway.
from ical4j.
Related Issues (20)
- Generic type definiton seems to be ignored HOT 4
- Ical4j 4.0.1 introduced duplicated classes
- MS timezone "Central America Standard Time" is transformed with DST
- Error loading timezone aliases - these dont exist in the locations specified in the code HOT 1
- NullPointerException in Configurator HOT 5
- VAlarm cannot be cast to class CalendarComponent HOT 2
- Version 4.0.2 ~40% slower than 3.2.18 HOT 2
- The Recur getDates method does not handle the transition from daylight saving to standard time the same in 4.x HOT 4
- Proguard breaks ical4j
- setValue in StructuredData constructor with single String parameter fails with a ConstraintViolationException "Missing required VALUE"
- Embedded Vtimezone for Asia/Shanghai incorrect
- Error loading timezone aliases: inStream parameter is null HOT 2
- PropertyBuilder: Should there be a "break" here? HOT 1
- compileTestJava fails with module split package errors HOT 1
- RecurSpec: verify recurrence rule with a specified interval fails HOT 4
- ByWeekNoRuleTest: verify transformations by week number (yearly) fails on `en_DK.UTF-8` HOT 1
- TemporalAmountAdapterTest > verify duration plus time operations: #duration > verify duration plus time operations: P1D FAILED
- Documentation is NOT up to date for the latest version HOT 1
- Cannot create a Jlink distribution with ical4j. Resource already present. HOT 1
- `Component.getRecurrenceSet` crashes when `period` starts at a date
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ical4j.