-
-
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.
Merge pull request #16 from ical4j/develop
Support prototypes
- Loading branch information
Showing
40 changed files
with
337 additions
and
20 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,21 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "ical4j-template-*" | ||
- "!ical4j-template-*-pre" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
# - name: Generate changelog | ||
# run: make changelog | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
generate_release_notes: true | ||
# body_path: CHANGELOG.md |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.ical4j.template; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.function.UnaryOperator; | ||
|
||
/** | ||
* A template encapsulates rules for creating and modifying complex iCalendar and | ||
* vCard objects. | ||
* | ||
* @param <T> the applicable object type | ||
*/ | ||
public interface Template<T> extends UnaryOperator<T> { | ||
|
||
/** | ||
* Apply the template to a new object instance. The use of this method requires | ||
* that the applicable object type contains a default noargs constructor that | ||
* can be used to create a new object instance. | ||
* @return a new object instance resulting from applying the template | ||
* @throws NoSuchMethodException if a noargs constructor doesn't exist on the applicable object type | ||
* @throws InvocationTargetException an error resulting from invoking the noargs constructor | ||
* @throws InstantiationException an error resulting from invoking the noargs constructor | ||
* @throws IllegalAccessException an error resulting from invoking the noargs constructor | ||
*/ | ||
T apply() throws NoSuchMethodException, InvocationTargetException, InstantiationException, | ||
IllegalAccessException; | ||
} |
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
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
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
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
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
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
70 changes: 70 additions & 0 deletions
70
src/main/java/org/ical4j/template/groupware/Individual.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.ical4j.template.groupware; | ||
|
||
import net.fortuna.ical4j.vcard.GeneralPropertyModifiers; | ||
import net.fortuna.ical4j.vcard.IdentificationPropertyModifiers; | ||
import net.fortuna.ical4j.vcard.VCard; | ||
import net.fortuna.ical4j.vcard.property.N; | ||
import net.fortuna.ical4j.vcard.property.immutable.ImmutableKind; | ||
import org.ical4j.template.AbstractTemplate; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Individual extends AbstractTemplate<VCard> { | ||
|
||
private String familyName; | ||
|
||
private String givenName; | ||
|
||
private final List<String> additionalNames = new ArrayList<>(); | ||
|
||
private final List<String> prefixes = new ArrayList<>(); | ||
|
||
private final List<String> suffixes = new ArrayList<>(); | ||
|
||
public Individual() { | ||
super(VCard.class); | ||
} | ||
|
||
public <T extends VCard> Individual(T prototype) { | ||
super(prototype.getClass()); | ||
setPrototype(prototype); | ||
} | ||
|
||
public Individual familyName(String familyName) { | ||
this.familyName = familyName; | ||
return this; | ||
} | ||
|
||
public Individual givenName(String givenName) { | ||
this.givenName = givenName; | ||
return this; | ||
} | ||
|
||
public Individual additionalName(String... additionalName) { | ||
this.additionalNames.addAll(Arrays.asList(additionalName)); | ||
return this; | ||
} | ||
|
||
public Individual prefix(String... prefix) { | ||
this.prefixes.addAll(Arrays.asList(prefix)); | ||
return this; | ||
} | ||
|
||
public Individual suffix(String... suffix) { | ||
this.suffixes.addAll(Arrays.asList(suffix)); | ||
return this; | ||
} | ||
|
||
@Override | ||
public VCard apply(VCard vCard) { | ||
applyPrototype(vCard); | ||
|
||
vCard.with(GeneralPropertyModifiers.KIND, ImmutableKind.INDIVIDUAL); | ||
vCard.with(IdentificationPropertyModifiers.N, new N(familyName, givenName, | ||
additionalNames.toArray(new String[0]), prefixes.toArray(new String[0]), | ||
suffixes.toArray(new String[0]))); | ||
return vCard; | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/org/ical4j/template/groupware/Organization.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.ical4j.template.groupware; | ||
|
||
import net.fortuna.ical4j.vcard.GeneralPropertyModifiers; | ||
import net.fortuna.ical4j.vcard.IdentificationPropertyModifiers; | ||
import net.fortuna.ical4j.vcard.VCard; | ||
import net.fortuna.ical4j.vcard.property.Fn; | ||
import net.fortuna.ical4j.vcard.property.immutable.ImmutableKind; | ||
import org.ical4j.template.AbstractTemplate; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Organization extends AbstractTemplate<VCard> { | ||
|
||
private final List<String> names = new ArrayList<>(); | ||
|
||
public Organization() { | ||
super(VCard.class); | ||
} | ||
|
||
public <T extends VCard> Organization(T prototype) { | ||
super(prototype.getClass()); | ||
setPrototype(prototype); | ||
} | ||
|
||
public Organization name(String...name) { | ||
names.addAll(Arrays.asList(name)); | ||
return this; | ||
} | ||
|
||
@Override | ||
public VCard apply(VCard vCard) { | ||
applyPrototype(vCard); | ||
|
||
vCard.with(GeneralPropertyModifiers.KIND, ImmutableKind.ORG); | ||
names.forEach(name -> vCard.with(IdentificationPropertyModifiers.FN, new Fn(name))); | ||
return vCard; | ||
} | ||
} |
Oops, something went wrong.