Skip to content

Commit 1f85bf2

Browse files
committed
feat: added some component properties
1 parent ac125d1 commit 1f85bf2

File tree

6 files changed

+329
-2
lines changed

6 files changed

+329
-2
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.onixbyte.icalendar.component.property;
19+
20+
import com.onixbyte.icalendar.datatype.CalendarUserAddress;
21+
import com.onixbyte.icalendar.property.parameter.*;
22+
23+
import java.util.Optional;
24+
25+
public final class Attendee implements ComponentProperty {
26+
27+
public static final String PROPERTY_NAME = "ATTENDEE";
28+
29+
private final CalendarUserType calendarUserType;
30+
31+
private final GroupOrListMembership groupOrListMembership;
32+
33+
private final ParticipationRole role;
34+
35+
private final ParticipationStatus status;
36+
37+
private final RsvpExpectation rsvp;
38+
39+
private final Delegatee delegatee;
40+
41+
private final Delegator delegator;
42+
43+
private final SentBy sentBy;
44+
45+
private final CommonName commonName;
46+
47+
private final DirectoryEntryReference directory;
48+
49+
private final Language language;
50+
51+
private final CalendarUserAddress value;
52+
53+
private Attendee(CalendarUserType calendarUserType,
54+
GroupOrListMembership groupOrListMembership,
55+
ParticipationRole role,
56+
ParticipationStatus status,
57+
RsvpExpectation rsvp,
58+
Delegatee delegatee,
59+
Delegator delegator,
60+
SentBy sentBy,
61+
CommonName commonName,
62+
DirectoryEntryReference directory,
63+
Language language,
64+
CalendarUserAddress value) {
65+
this.calendarUserType = calendarUserType;
66+
this.groupOrListMembership = groupOrListMembership;
67+
this.role = role;
68+
this.status = status;
69+
this.rsvp = rsvp;
70+
this.delegatee = delegatee;
71+
this.delegator = delegator;
72+
this.sentBy = sentBy;
73+
this.commonName = commonName;
74+
this.directory = directory;
75+
this.language = language;
76+
this.value = value;
77+
}
78+
79+
public static class Builder {
80+
private CalendarUserType calendarUserType;
81+
82+
private GroupOrListMembership groupOrListMembership;
83+
84+
private ParticipationRole role;
85+
86+
private ParticipationStatus status;
87+
88+
private RsvpExpectation rsvp;
89+
90+
private Delegatee delegatee;
91+
92+
private Delegator delegator;
93+
94+
private SentBy sentBy;
95+
96+
private CommonName commonName;
97+
98+
private DirectoryEntryReference directory;
99+
100+
private Language language;
101+
102+
private CalendarUserAddress attendee;
103+
104+
private Builder() {
105+
}
106+
107+
public Builder calendarUserType(CalendarUserType calendarUserType) {
108+
this.calendarUserType = calendarUserType;
109+
return this;
110+
}
111+
112+
public Builder groupOrListMembership(GroupOrListMembership groupOrListMembership) {
113+
this.groupOrListMembership = groupOrListMembership;
114+
return this;
115+
}
116+
117+
public Builder role(ParticipationRole role) {
118+
this.role = role;
119+
return this;
120+
}
121+
122+
public Builder status(ParticipationStatus status) {
123+
this.status = status;
124+
return this;
125+
}
126+
127+
public Builder rsvp(RsvpExpectation rsvp) {
128+
this.rsvp = rsvp;
129+
return this;
130+
}
131+
132+
public Builder delegatee(Delegatee delegatee) {
133+
this.delegatee = delegatee;
134+
return this;
135+
}
136+
137+
public Builder delegator(Delegator delegator) {
138+
this.delegator = delegator;
139+
return this;
140+
}
141+
142+
public Builder sentBy(SentBy sentBy) {
143+
this.sentBy = sentBy;
144+
return this;
145+
}
146+
147+
public Builder commonName(CommonName commonName) {
148+
this.commonName = commonName;
149+
return this;
150+
}
151+
152+
public Builder directory(DirectoryEntryReference directory) {
153+
this.directory = directory;
154+
return this;
155+
}
156+
157+
public Builder language(Language language) {
158+
this.language = language;
159+
return this;
160+
}
161+
162+
public Builder attendee(CalendarUserAddress calendarUserAddress) {
163+
this.attendee = calendarUserAddress;
164+
return this;
165+
}
166+
167+
public Attendee build() {
168+
return new Attendee(calendarUserType, groupOrListMembership, role, status, rsvp,
169+
delegatee, delegator, sentBy, commonName, directory, language, attendee);
170+
}
171+
}
172+
173+
public static Builder builder() {
174+
return new Builder();
175+
}
176+
177+
@Override
178+
public String resolve() {
179+
var builder = new StringBuilder(PROPERTY_NAME);
180+
181+
builder.append(Optional.ofNullable(calendarUserType)
182+
.map(CalendarUserType::resolve)
183+
.orElse(""))
184+
.append(Optional.ofNullable(groupOrListMembership)
185+
.map(GroupOrListMembership::resolve)
186+
.orElse(""))
187+
.append(Optional.ofNullable(role)
188+
.map(ParticipationRole::resolve)
189+
.orElse(""))
190+
.append(Optional.ofNullable(status)
191+
.map(ParticipationStatus::resolve)
192+
.orElse(""))
193+
.append(Optional.ofNullable(rsvp)
194+
.map(RsvpExpectation::resolve)
195+
.orElse(""))
196+
.append(Optional.ofNullable(delegatee)
197+
.map(Delegatee::resolve)
198+
.orElse(""))
199+
.append(Optional.ofNullable(delegator)
200+
.map(Delegator::resolve)
201+
.orElse(""))
202+
.append(Optional.ofNullable(sentBy)
203+
.map(SentBy::resolve)
204+
.orElse(""))
205+
.append(Optional.ofNullable(commonName)
206+
.map(CommonName::resolve)
207+
.orElse(""));
208+
// .append()
209+
210+
211+
return "";
212+
}
213+
}
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package com.onixbyte.icalendar.component.property;
219

3-
public record TimeZoneOffsetFrom() {
20+
import com.onixbyte.icalendar.datatype.UtcOffset;
21+
22+
public record TimeZoneOffsetFrom(UtcOffset offset) implements ComponentProperty {
23+
24+
private static final String PROPERTY_NAME = "TZOFFSETFROM";
25+
26+
@Override
27+
public String resolve() {
28+
return PROPERTY_NAME + ":" + offset.resolve() + "\n";
29+
}
430
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.onixbyte.icalendar.component.property;
19+
20+
import com.onixbyte.icalendar.datatype.UtcOffset;
21+
22+
public record TimeZoneOffsetTo(UtcOffset offset) implements ComponentProperty {
23+
24+
public static final String PROPERTY_NAME = "TZOFFSETTO";
25+
26+
@Override
27+
public String resolve() {
28+
return PROPERTY_NAME + ":" + offset.resolve() + "\n";
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.onixbyte.icalendar.component.property;
19+
20+
import java.net.URI;
21+
22+
public record TimeZoneUrl(URI uri) implements ComponentProperty {
23+
24+
public static final String PROPERTY_NAME = "TZURL";
25+
26+
@Override
27+
public String resolve() {
28+
return PROPERTY_NAME + ":" + uri + "\n";
29+
}
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2024-2024 OnixByte.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
*
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.onixbyte.icalendar.datatype;
19+
20+
import com.onixbyte.icalendar.property.Resolvable;
21+
22+
public record UtcOffset(char sign, int hour, int minute) implements Resolvable {
23+
24+
@Override
25+
public String resolve() {
26+
return "%c%02d%02d".formatted(sign, hour, minute);
27+
}
28+
}

webcal/src/main/java/com/onixbyte/icalendar/property/parameter/UserType.java renamed to webcal/src/main/java/com/onixbyte/icalendar/property/parameter/CalendarUserType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @author Zihlu WANG
2424
*/
25-
public enum UserType implements PropertyParameter {
25+
public enum CalendarUserType implements PropertyParameter {
2626

2727
/**
2828
* An individual.

0 commit comments

Comments
 (0)