-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added factory to create template from concept
- Loading branch information
1 parent
afe9059
commit dbd7aa8
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.ical4j.template; | ||
|
||
import net.fortuna.ical4j.extensions.concept.ActionType; | ||
import net.fortuna.ical4j.extensions.concept.EventType; | ||
import net.fortuna.ical4j.model.component.VEvent; | ||
import net.fortuna.ical4j.model.component.VToDo; | ||
import net.fortuna.ical4j.model.property.Concept; | ||
import org.ical4j.template.groupware.Action; | ||
import org.ical4j.template.groupware.Meeting; | ||
|
||
import java.util.function.UnaryOperator; | ||
|
||
public class TemplateFactory { | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> UnaryOperator<T> newInstance(Concept concept) { | ||
if (EventType.MEETING.equals(concept)) { | ||
return (UnaryOperator<T>) new Meeting(); | ||
} else if (ActionType.ACTION.equals(concept)) { | ||
return (UnaryOperator<T>) new Action(); | ||
// } else if (ActionType.AGENDA.equals(concept)) { | ||
// return (UnaryOperator<T>) new Agenda(); | ||
} | ||
throw new IllegalArgumentException("Unknown concept"); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> UnaryOperator<T> newInstance(Concept concept, T prototype) { | ||
if (EventType.MEETING.equals(concept)) { | ||
return (UnaryOperator<T>) new Meeting((VEvent) prototype); | ||
} else if (ActionType.ACTION.equals(concept)) { | ||
return (UnaryOperator<T>) new Action((VToDo) prototype); | ||
// } else if (ActionType.AGENDA.equals(concept)) { | ||
// return (UnaryOperator<T>) new Agenda(); | ||
} | ||
throw new IllegalArgumentException("Unknown concept"); | ||
} | ||
} |