|
9 | 9 | import java.net.URISyntaxException;
|
10 | 10 | import java.security.NoSuchAlgorithmException;
|
11 | 11 | import java.util.Arrays;
|
| 12 | +import java.util.Objects; |
12 | 13 |
|
13 | 14 | import io.literal.lib.Crypto;
|
14 | 15 | import io.literal.lib.JsonArrayUtil;
|
@@ -66,8 +67,9 @@ public static Id fromString(String json) {
|
66 | 67 | }
|
67 | 68 | }
|
68 | 69 |
|
| 70 | + @NotNull |
69 | 71 | public String toString() {
|
70 |
| - if (type.equals(Type.IRI)) { |
| 72 | + if (type.equals(Type.IRI) && iri != null) { |
71 | 73 | return iri;
|
72 | 74 | }
|
73 | 75 | return storageObject.getCanonicalURI().toString();
|
@@ -215,4 +217,81 @@ public PatchAnnotationOperationInput toPatchAnnotationOperationInputSet() {
|
215 | 217 | )
|
216 | 218 | .build();
|
217 | 219 | }
|
| 220 | + |
| 221 | + public static class Builder { |
| 222 | + private Id id; |
| 223 | + private Format format; |
| 224 | + private Language language; |
| 225 | + private Language processingLanguage; |
| 226 | + private TextDirection textDirection; |
| 227 | + private ResourceType resourceType; |
| 228 | + private String[] accessibility; |
| 229 | + private String[] rights; |
| 230 | + |
| 231 | + public Builder(ExternalTarget base) { |
| 232 | + this.id = base.getId(); |
| 233 | + this.format = base.getFormat(); |
| 234 | + this.language = base.getLanguage(); |
| 235 | + this.processingLanguage = base.getProcessingLanguage(); |
| 236 | + this.textDirection = base.getTextDirection(); |
| 237 | + this.resourceType = base.getResourceType(); |
| 238 | + this.accessibility = base.getAccessibility(); |
| 239 | + this.rights = base.getRights(); |
| 240 | + } |
| 241 | + |
| 242 | + public Builder setId(Id id) { |
| 243 | + this.id = id; |
| 244 | + return this; |
| 245 | + } |
| 246 | + |
| 247 | + public Builder setFormat(Format format) { |
| 248 | + this.format = format; |
| 249 | + return this; |
| 250 | + } |
| 251 | + |
| 252 | + public Builder setLanguage(Language language) { |
| 253 | + this.language = language; |
| 254 | + return this; |
| 255 | + } |
| 256 | + |
| 257 | + public Builder setProcessingLanguage(Language processingLanguage) { |
| 258 | + this.processingLanguage = processingLanguage; |
| 259 | + return this; |
| 260 | + } |
| 261 | + |
| 262 | + public Builder setTextDirection(TextDirection textDirection) { |
| 263 | + this.textDirection = textDirection; |
| 264 | + return this; |
| 265 | + } |
| 266 | + |
| 267 | + public Builder setResourceType(ResourceType resourceType) { |
| 268 | + this.resourceType = resourceType; |
| 269 | + return this; |
| 270 | + } |
| 271 | + |
| 272 | + public Builder setAccessibility(String[] accessibility) { |
| 273 | + this.accessibility = accessibility; |
| 274 | + return this; |
| 275 | + } |
| 276 | + |
| 277 | + public Builder setRights(String[] rights) { |
| 278 | + this.rights = rights; |
| 279 | + return this; |
| 280 | + } |
| 281 | + |
| 282 | + public ExternalTarget build() { |
| 283 | + Objects.requireNonNull(id); |
| 284 | + |
| 285 | + return new ExternalTarget( |
| 286 | + id, |
| 287 | + format, |
| 288 | + language, |
| 289 | + processingLanguage, |
| 290 | + textDirection, |
| 291 | + accessibility, |
| 292 | + rights, |
| 293 | + resourceType |
| 294 | + ); |
| 295 | + } |
| 296 | + } |
218 | 297 | }
|
0 commit comments