diff --git a/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarProperty.java b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarProperty.java new file mode 100644 index 0000000..5744014 --- /dev/null +++ b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarProperty.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024-2024 OnixByte. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.onixbyte.icalendar.calendar.property; + +import com.onixbyte.icalendar.property.CalendarResolvable; + +public interface CalendarProperty extends CalendarResolvable { +} diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/CalendarScale.java b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarScale.java similarity index 85% rename from webcal/src/main/java/com/onixbyte/icalendar/property/calendar/CalendarScale.java rename to webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarScale.java index ab07b53..dc95f73 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/CalendarScale.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/CalendarScale.java @@ -15,16 +15,14 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.calendar; - -import com.onixbyte.icalendar.property.Prop; +package com.onixbyte.icalendar.calendar.property; /** * CalendarScale * * @author Zihlu WANG */ -public enum CalendarScale implements Prop { +public enum CalendarScale implements CalendarProperty { GREGORIAN, ; diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Method.java b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Method.java similarity index 89% rename from webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Method.java rename to webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Method.java index a141e58..8f7c422 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Method.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Method.java @@ -15,11 +15,9 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.calendar; +package com.onixbyte.icalendar.calendar.property; -import com.onixbyte.icalendar.property.Prop; - -public enum Method implements Prop { +public enum Method implements CalendarProperty { PUBLISH("PUBLISH"), REQUEST("REQUEST"), diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/ProductIdentifier.java b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/ProductIdentifier.java similarity index 68% rename from webcal/src/main/java/com/onixbyte/icalendar/property/calendar/ProductIdentifier.java rename to webcal/src/main/java/com/onixbyte/icalendar/calendar/property/ProductIdentifier.java index 2ebbd96..999308c 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/ProductIdentifier.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/ProductIdentifier.java @@ -15,18 +15,16 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.calendar; - -import com.onixbyte.icalendar.property.Prop; +package com.onixbyte.icalendar.calendar.property; /** * ProductIdentifier * * @author Zihlu WANG */ -public final class ProductIdentifier implements Prop { +public final class ProductIdentifier implements CalendarProperty { - private String value; + private final String value; @Override public String resolve() { @@ -34,29 +32,28 @@ public final class ProductIdentifier implements Prop { } public static class Builder { - private final ProductIdentifier productIdentifier; + private String productIdentifier; private Builder() { - this.productIdentifier = new ProductIdentifier(); } public Builder productIdentifier(String productIdentifier) { - this.productIdentifier.value = productIdentifier; + this.productIdentifier = productIdentifier; return this; } public Builder productIdentifier(String companyName, String productName) { - this.productIdentifier.value = "-//" + companyName + "//" + productName + "//EN"; + this.productIdentifier = "-//" + companyName + "//" + productName + "//EN"; return this; } public Builder productIdentifier(String companyName, String productName, String languageTag) { - this.productIdentifier.value = "-//" + companyName + "//" + productName + "//" + languageTag; + this.productIdentifier = "-//" + companyName + "//" + productName + "//" + languageTag; return this; } public ProductIdentifier build() { - return productIdentifier; + return new ProductIdentifier(productIdentifier); } } @@ -66,6 +63,7 @@ public final class ProductIdentifier implements Prop { private static final String PROPERTY_NAME = "PRODID"; - private ProductIdentifier() { + private ProductIdentifier(String value) { + this.value = value; } } diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Version.java b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Version.java similarity index 85% rename from webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Version.java rename to webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Version.java index ac4ed00..7c4784a 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/calendar/Version.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/calendar/property/Version.java @@ -15,16 +15,14 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.calendar; - -import com.onixbyte.icalendar.property.Prop; +package com.onixbyte.icalendar.calendar.property; /** * Version * * @author Zihlu WANG */ -public enum Version implements Prop { +public enum Version implements CalendarProperty { VERSION_2_0, ; diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/Calendar.java b/webcal/src/main/java/com/onixbyte/icalendar/component/Calendar.java index dd9d386..ba7213a 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/component/Calendar.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/Calendar.java @@ -17,10 +17,10 @@ package com.onixbyte.icalendar.component; -import com.onixbyte.icalendar.property.calendar.CalendarScale; -import com.onixbyte.icalendar.property.calendar.Method; -import com.onixbyte.icalendar.property.calendar.ProductIdentifier; -import com.onixbyte.icalendar.property.calendar.Version; +import com.onixbyte.icalendar.calendar.property.CalendarScale; +import com.onixbyte.icalendar.calendar.property.Method; +import com.onixbyte.icalendar.calendar.property.ProductIdentifier; +import com.onixbyte.icalendar.calendar.property.Version; import java.util.ArrayList; import java.util.List; @@ -100,9 +100,7 @@ public final class Calendar { .ifPresent((_method) -> calendarBuilder.append(_method.resolve()).append('\n')); if (!components.isEmpty()) { - for (var component : components) { - calendarBuilder.append(component.resolve()).append('\n'); - } + components.forEach(((component) -> calendarBuilder.append(component.resolve()).append('\n'))); } calendarBuilder.append("END:").append(COMPONENT_NAME).append('\n'); diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/CalendarComponent.java b/webcal/src/main/java/com/onixbyte/icalendar/component/CalendarComponent.java index 3768d32..0b2cf27 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/component/CalendarComponent.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/CalendarComponent.java @@ -18,10 +18,12 @@ package com.onixbyte.icalendar.component; /** - * The abstract sealed class {@code WebCalendarNode} represents a node in a web calendar, such as an event, a to-do - * item, or an alarm. It provides common properties and methods for all calendar components and events. + * The abstract sealed class {@code WebCalendarNode} represents a node in a web calendar, such as an + * event, a to-do item, or an alarm. It provides common properties and + * methods for all calendar components and events. *
- * Subclasses of {@code WebCalendarNode} should implement the {@link #resolve()} method to generate the corresponding iCalendar content for the specific calendar component or event. + * Subclasses of {@code WebCalendarNode} should implement the {@link #resolve()} method to generate + * the corresponding iCalendar content for the specific calendar component or event. * * @author Zihlu Wang * @version 1.1.0 diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/Event.java b/webcal/src/main/java/com/onixbyte/icalendar/component/Event.java index e6265e4..bf88742 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/component/Event.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/Event.java @@ -17,8 +17,9 @@ package com.onixbyte.icalendar.component; -import com.onixbyte.icalendar.property.component.DateTimeStamp; -import com.onixbyte.icalendar.property.component.UniqueIdentifier; +import com.onixbyte.icalendar.component.property.Classification; +import com.onixbyte.icalendar.component.property.DateTimeStamp; +import com.onixbyte.icalendar.component.property.UniqueIdentifier; /** * Event @@ -27,11 +28,39 @@ import com.onixbyte.icalendar.property.component.UniqueIdentifier; */ public class Event extends CalendarComponent { + /* + * The following properties are REQUIRED, but MUST NOT occur more than once. + */ + + /** + * + */ private DateTimeStamp dtStamp; + /** + * + */ private UniqueIdentifier uid; + /* + * The following property is REQUIRED if the component appears in an iCalendar object that + * doesn't specify the "METHOD" property; otherwise, it is OPTIONAL; in any case, it MUST NOT + * occur more than once. + */ + /** + * + */ + private DateTimeStamp dtStart; + + /* + * The following properties are OPTIONAL, but MUST NOT occur more than once. + */ + + /** + * + */ + private Classification classification; @Override public String resolve() { diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/component/Attach.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Attachment.java similarity index 63% rename from webcal/src/main/java/com/onixbyte/icalendar/property/component/Attach.java rename to webcal/src/main/java/com/onixbyte/icalendar/component/property/Attachment.java index 4ddda6e..b37f999 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/component/Attach.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Attachment.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.component; +package com.onixbyte.icalendar.component.property; -import com.onixbyte.icalendar.property.Prop; import com.onixbyte.icalendar.property.parameter.FormatType; import java.net.URI; +import java.util.Optional; /** - * Attach + * Attachment * * @author Zihlu WANG */ -public final class Attach implements Prop { +public final class Attachment implements ComponentProperty { private FormatType formatType; @@ -35,6 +35,14 @@ public final class Attach implements Prop { @Override public String resolve() { - return ""; + final var attachmentBuilder = new StringBuilder("ATTACH"); + + Optional.ofNullable(formatType) + .ifPresent((fmtType) -> attachmentBuilder.append(fmtType.resolve())); + + attachmentBuilder.append(":") + .append(uri.toString()); + + return attachmentBuilder.toString(); } } diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/property/Categories.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Categories.java new file mode 100644 index 0000000..b0ff2d9 --- /dev/null +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Categories.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024-2024 OnixByte. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.onixbyte.icalendar.component.property; + +public class Categories { +} diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/property/Classification.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Classification.java new file mode 100644 index 0000000..2770a93 --- /dev/null +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/Classification.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024-2024 OnixByte. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.onixbyte.icalendar.component.property; + +public enum Classification { +} diff --git a/webcal/src/main/java/com/onixbyte/icalendar/component/property/ComponentProperty.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/ComponentProperty.java new file mode 100644 index 0000000..ae2f910 --- /dev/null +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/ComponentProperty.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024-2024 OnixByte. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.onixbyte.icalendar.component.property; + +import com.onixbyte.icalendar.property.CalendarResolvable; + +public interface ComponentProperty extends CalendarResolvable { +} diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeCreated.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeCreated.java similarity index 93% rename from webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeCreated.java rename to webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeCreated.java index 26d2f3a..e2b4e34 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeCreated.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeCreated.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.component; +package com.onixbyte.icalendar.component.property; /** * DateTimeCreated diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeStamp.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeStamp.java similarity index 83% rename from webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeStamp.java rename to webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeStamp.java index 743efee..21f902f 100644 --- a/webcal/src/main/java/com/onixbyte/icalendar/property/component/DateTimeStamp.java +++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/DateTimeStamp.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package com.onixbyte.icalendar.property.component; +package com.onixbyte.icalendar.component.property; +import com.onixbyte.icalendar.calendar.property.Method; import com.onixbyte.icalendar.config.Formatters; -import com.onixbyte.icalendar.property.Prop; import java.time.LocalDateTime; /** * In the case of an {@link com.onixbyte.icalendar.component.Calendar iCalendar} object that specifies a "{@link - * com.onixbyte.icalendar.property.calendar.Method Method}" property, this property specifies the date and time that + * Method Method}" property, this property specifies the date and time that * the instance of the {@link com.onixbyte.icalendar.component.Calendar iCalendar} object was created. In the case of * an {@link com.onixbyte.icalendar.component.Calendar iCalendar} object that doesn't specify a "{@link - * com.onixbyte.icalendar.property.calendar.Method Method}" property, this property specifies the date and time that + * Method Method}" property, this property specifies the date and time that * the information associated with the calendar component was last revised in the calendar store. *
* The value MUST be specified in the UTC time format. @@ -37,19 +37,19 @@ import java.time.LocalDateTime; * com.onixbyte.icalendar.component.Calendar iCalendar} objects. *
* In the case of an {@link com.onixbyte.icalendar.component.Calendar iCalendar} object that specifies a "{@link - * com.onixbyte.icalendar.property.calendar.Method Method}" property, this property differs from the "{@link + * Method Method}" property, this property differs from the "{@link * DateTimeCreated CREATED}" and "{@link LastModified LAST-MODIFIED}" properties. These two properties are used to * specify when the particular calendar data in the calendar store was created and last modified. This is different * from when the {@link com.onixbyte.icalendar.component.Calendar iCalendar} object representation of the calendar * service information was created or last modified. *
* In the case of an {@link com.onixbyte.icalendar.component.Calendar iCalendar} object that specifies a "{@link
- * com.onixbyte.icalendar.property.calendar.Method METHOD}" property, this property is equivalent to the "{@link
+ * Method METHOD}" property, this property is equivalent to the "{@link
* LastModified LAST-MODIFIED}" property.
*
* @author Zihlu WANG
*/
-public final class DateTimeStamp implements Prop {
+public final class DateTimeStamp implements ComponentProperty {
private static final String PROPERTY_NAME = "DTSTAMP";
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/component/LastModified.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/LastModified.java
similarity index 93%
rename from webcal/src/main/java/com/onixbyte/icalendar/property/component/LastModified.java
rename to webcal/src/main/java/com/onixbyte/icalendar/component/property/LastModified.java
index 6c2f0bb..21b3ddd 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/component/LastModified.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/LastModified.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.onixbyte.icalendar.property.component;
+package com.onixbyte.icalendar.component.property;
/**
* LastModified
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/component/UniqueIdentifier.java b/webcal/src/main/java/com/onixbyte/icalendar/component/property/UniqueIdentifier.java
similarity index 91%
rename from webcal/src/main/java/com/onixbyte/icalendar/property/component/UniqueIdentifier.java
rename to webcal/src/main/java/com/onixbyte/icalendar/component/property/UniqueIdentifier.java
index 52af13c..b27ab46 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/component/UniqueIdentifier.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/component/property/UniqueIdentifier.java
@@ -15,16 +15,14 @@
* limitations under the License.
*/
-package com.onixbyte.icalendar.property.component;
-
-import com.onixbyte.icalendar.property.Prop;
+package com.onixbyte.icalendar.component.property;
/**
* UniqueIdentifier
*
* @author Zihlu WANG
*/
-public final class UniqueIdentifier implements Prop {
+public final class UniqueIdentifier implements ComponentProperty {
private String value;
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/datatype/CalendarUserAddress.java b/webcal/src/main/java/com/onixbyte/icalendar/datatype/CalendarUserAddress.java
new file mode 100644
index 0000000..25f7df0
--- /dev/null
+++ b/webcal/src/main/java/com/onixbyte/icalendar/datatype/CalendarUserAddress.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2024-2024 OnixByte.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.onixbyte.icalendar.datatype;
+
+import java.net.URI;
+
+public final class CalendarUserAddress {
+
+ private URI value;
+
+ public CalendarUserAddress(URI value) {
+ if (!"mailto".equalsIgnoreCase(value.getScheme())) {
+ throw new IllegalArgumentException("Calendar User Address (CAL-ADDRESS) only accept mailto URI.");
+ }
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value.toString();
+ }
+}
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/Prop.java b/webcal/src/main/java/com/onixbyte/icalendar/property/CalendarResolvable.java
similarity index 94%
rename from webcal/src/main/java/com/onixbyte/icalendar/property/Prop.java
rename to webcal/src/main/java/com/onixbyte/icalendar/property/CalendarResolvable.java
index ba4b51b..b8f2fd2 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/Prop.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/property/CalendarResolvable.java
@@ -17,7 +17,7 @@
package com.onixbyte.icalendar.property;
-public interface Prop {
+public interface CalendarResolvable {
String resolve();
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/AlternateRepresentation.java b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/AlternateRepresentation.java
index 0a03003..56a35dc 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/AlternateRepresentation.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/AlternateRepresentation.java
@@ -17,7 +17,7 @@
package com.onixbyte.icalendar.property.parameter;
-import com.onixbyte.icalendar.property.Prop;
+import com.onixbyte.icalendar.property.CalendarResolvable;
import java.net.URI;
@@ -33,33 +33,43 @@ import java.net.URI;
*
* @author Zihlu Wang
*/
-public final class AlternateRepresentation implements Prop {
+public final class AlternateRepresentation implements PropertyParameter {
private static final String PROPERTY_NAME = "ALTREP";
- private URI uri;
+ private URI value;
- private AlternateRepresentation() {
- }
-
- public AlternateRepresentation setUri(String uri) {
- this.uri = URI.create(uri);
- return this;
- }
-
- public AlternateRepresentation setUri(URI uri) {
- this.uri = uri;
- return this;
- }
-
- public static AlternateRepresentation createInstance(String uri) {
- var instance = new AlternateRepresentation();
- instance.uri = URI.create(uri);
- return instance;
+ private AlternateRepresentation(URI uri) {
+ this.value = uri;
}
@Override
public String resolve() {
- return PROPERTY_NAME + "=\"" + uri.toString() + "\"";
+ return PROPERTY_NAME + "=\"" + value.toString() + "\"";
+ }
+
+ public static class Builder {
+ private URI uri;
+
+ private Builder() {
+ }
+
+ public Builder uri(String uri) {
+ this.uri = URI.create(uri);
+ return this;
+ }
+
+ public Builder uri(URI uri) {
+ this.uri = uri;
+ return this;
+ }
+
+ public AlternateRepresentation build() {
+ return new AlternateRepresentation(uri);
+ }
+ }
+
+ public static Builder builder() {
+ return new Builder();
}
}
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CalendarUserType.java b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CalendarUserType.java
index 0ab14ae..a0dda83 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CalendarUserType.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CalendarUserType.java
@@ -17,14 +17,14 @@
package com.onixbyte.icalendar.property.parameter;
-import com.onixbyte.icalendar.property.Prop;
+import com.onixbyte.icalendar.property.CalendarResolvable;
/**
* CalendarUserType
*
* @author Zihlu WANG
*/
-public enum CalendarUserType implements Prop {
+public enum CalendarUserType implements PropertyParameter {
/**
* An individual.
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CommonName.java b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CommonName.java
index 5b8899c..e4fc7b4 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CommonName.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CommonName.java
@@ -17,7 +17,7 @@
package com.onixbyte.icalendar.property.parameter;
-import com.onixbyte.icalendar.property.Prop;
+import com.onixbyte.icalendar.property.CalendarResolvable;
/**
* Common Name can be specified on properties with a CAL-ADDRESS value type. The parameter
@@ -27,26 +27,38 @@ import com.onixbyte.icalendar.property.Prop;
*
* @author Zihlu Wang
*/
-public final class CommonName implements Prop {
+public final class CommonName implements PropertyParameter {
- private String value;
+ private static final String PROPERTY_NAME = "CN";
- private CommonName() {
- }
+ private final String value;
- public CommonName setValue(String value) {
+ private CommonName(String value) {
this.value = value;
- return this;
}
- public static CommonName createInstance(String commonName) {
- var instance = new CommonName();
- instance.value = commonName;
- return instance;
+ public static class Builder {
+ private String value;
+
+ private Builder() {
+ }
+
+ public Builder commonName(String commonName) {
+ this.value = commonName;
+ return this;
+ }
+
+ public CommonName build() {
+ return new CommonName(value);
+ }
+ }
+
+ public static Builder builder() {
+ return new Builder();
}
@Override
public String resolve() {
- return "CN=\"" + this.value + "\"";
+ return PROPERTY_NAME + "=\"" + this.value + "\"";
}
}
diff --git a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/Delegatee.java b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/Delegatee.java
index 75d8610..bcfae0e 100644
--- a/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/Delegatee.java
+++ b/webcal/src/main/java/com/onixbyte/icalendar/property/parameter/Delegatee.java
@@ -17,10 +17,49 @@
package com.onixbyte.icalendar.property.parameter;
+import com.onixbyte.icalendar.datatype.CalendarUserAddress;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Delegate
*
* @author Zihlu WANG
*/
-public class Delegatee {
+public final class Delegatee implements PropertyParameter {
+
+ private static final String PROPERTY_NAME = "DELEGATED-TO";
+
+ private final List