Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative wrapping #96

Draft
wants to merge 152 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
ac9290c
WIP
langsamu Aug 5, 2023
3dba2d4
Generating a source file
langsamu Aug 6, 2023
1edc618
Java 8
langsamu Aug 6, 2023
9e16a12
Add example of nested wrapper interface
langsamu Aug 6, 2023
1be858c
Tidy
langsamu Aug 6, 2023
2b9872a
Generate some more
langsamu Aug 6, 2023
03df564
Generate files that compile for three annotations
langsamu Aug 6, 2023
f15dd4d
Tidy
langsamu Aug 6, 2023
a7f2d43
Style
langsamu Aug 12, 2023
716cee2
Java 8 compatible Generated annotation
langsamu Aug 12, 2023
c79ac9a
Move manager to processing module
langsamu Aug 12, 2023
7864296
Generate dataset wrap method
langsamu Aug 12, 2023
bb1816d
Generate graph wrap method
langsamu Aug 12, 2023
bc03554
Generate with JDeparser
langsamu Aug 12, 2023
610e3a7
Merge branch 'main' into declarative_wrapping
langsamu Aug 12, 2023
25bddf8
Tidy Processor
langsamu Aug 19, 2023
9da7b6b
Implement `@DefaultGraph`
langsamu Aug 19, 2023
3cffe9e
Tidy processor tests
langsamu Aug 19, 2023
28b092e
Implement `@NamedGraph`
langsamu Aug 19, 2023
5539f5c
Implement `@FirstInstanceOf`
langsamu Aug 19, 2023
d41e081
Tidy Processor
langsamu Aug 19, 2023
2df57f5
Add simple E2E unit test
langsamu Aug 19, 2023
dde62bb
Separate implementors from processor
langsamu Aug 19, 2023
79f3c24
Style
langsamu Aug 19, 2023
a3c27da
Extract `Implementor#membersAnnotatedWith`
langsamu Aug 20, 2023
9fcf2ff
Tidy Implementors
langsamu Aug 20, 2023
1de14bb
Extend `@FirstInstance` to multiple classes
langsamu Aug 20, 2023
5cbee86
Discard annotations at compile
langsamu Aug 20, 2023
d494318
Ignore literals in instance selector
langsamu Aug 20, 2023
f160565
Don't reuse classes in instance selector
langsamu Aug 20, 2023
8d0973b
Naming
langsamu Aug 20, 2023
3ae2b15
Implement `@FirstSubjectOf`
langsamu Aug 20, 2023
a52b047
Implement `@FirstObjectOf`
langsamu Aug 20, 2023
c6ccf0d
Easy on the generated imports
langsamu Aug 20, 2023
aa7a899
Only add to personality once
langsamu Aug 20, 2023
25a8fb0
Found how to generate `this` properly
langsamu Aug 20, 2023
16b0629
Validation in processor
langsamu Aug 27, 2023
2905c33
Merge branch 'main' into declarative_wrapping
langsamu Aug 27, 2023
76f6c2e
Use implementation not interface to generate dataset methods
langsamu Aug 28, 2023
974c719
Test compile-time validation of declarative wrapping
langsamu Aug 28, 2023
0c7bacd
Remove template module
langsamu Aug 28, 2023
dc6809f
Fold test module into processor
langsamu Aug 28, 2023
a5a016f
Hoist declarative modules
langsamu Sep 9, 2023
3058625
Merge branch 'main' into declarative_wrapping
langsamu Sep 9, 2023
e12e53c
Type-safe annotation handling
langsamu Sep 9, 2023
d7b1abd
Report processor coverage
langsamu Sep 9, 2023
a700b10
Tidy dataset implementor
langsamu Sep 9, 2023
e9d6a08
Merge branch 'main' into declarative_wrapping
langsamu Sep 29, 2023
0123c9a
Tidy graph implementor
langsamu Sep 29, 2023
5f54a0f
Validate graph methods return resources
langsamu Sep 29, 2023
4437633
Validate dataset methods return graphs
langsamu Sep 29, 2023
815c162
Tidy validators
langsamu Sep 29, 2023
9bcbd88
Reminder
langsamu Sep 30, 2023
828e257
Initial property in resource implementor
langsamu Sep 30, 2023
7fd4b64
Tidy
langsamu Sep 30, 2023
8e92376
Support dynamic property mapping
langsamu Oct 1, 2023
951996f
Validate resource property return matches mapper
langsamu Oct 1, 2023
b152bc4
Extract a processing environment helper
langsamu Oct 8, 2023
28a4023
Don't generate explicit `this`
langsamu Oct 8, 2023
2983cb6
Simplify
langsamu Oct 8, 2023
ffe18fb
Separate representations for implementation and interface
langsamu Oct 14, 2023
2cda65a
Helper
langsamu Oct 14, 2023
72ddc61
First step to resource properties
langsamu Oct 14, 2023
206f71b
Transitive personality
langsamu Oct 14, 2023
a738139
Merge branch 'main' into declarative_wrapping
langsamu Oct 14, 2023
eba597e
Style
langsamu Oct 14, 2023
7ec4707
Simplify interface representations
langsamu Oct 15, 2023
0040216
Tidy implementation
langsamu Oct 15, 2023
7fca8f0
Cover Mapping->ValueMappings equivalence
langsamu Oct 21, 2023
ccbb2f8
Typo
langsamu Oct 21, 2023
94d5a61
Leaner validation error
langsamu Oct 21, 2023
e9190eb
Validate that complex property methods of resource interfaces return …
langsamu Oct 21, 2023
d0b3500
Cleanup
langsamu Oct 21, 2023
645f938
Tidy
langsamu Oct 21, 2023
c98f01b
This was so long ago that I don't remember
langsamu Feb 17, 2024
276a111
Generic validators
langsamu Feb 17, 2024
1927ae2
Simplify type & env in Implementer
langsamu Feb 17, 2024
3398a79
Simplify
langsamu Feb 17, 2024
938e4a8
Move from implementor to Interface
langsamu Feb 17, 2024
722cf15
Implementations have interface
langsamu Feb 17, 2024
f1ec5d5
Eliminate implementation
langsamu Feb 17, 2024
4b03d88
Style
langsamu Feb 17, 2024
d578953
Manager readability and coverage
langsamu Feb 17, 2024
8cf27e0
Extract wrapping processing environment
langsamu Feb 17, 2024
4206261
Tidy implementor test
langsamu Feb 18, 2024
4aef332
More reliance on interfaces
langsamu Feb 18, 2024
752a7a3
Cover wrapper processing environment
langsamu Feb 18, 2024
9119dcc
Merge branch 'main' into declarative_wrapping
langsamu Feb 18, 2024
c005630
Represent all value mapping methods
langsamu Feb 18, 2024
9dc786c
Better describe property mapping correspondence
langsamu Feb 18, 2024
0afc6a6
Validate the resource property methods are not void
langsamu Feb 18, 2024
d2c9d00
Reproduce cycle on recursive resource property types
langsamu Feb 21, 2024
a13005c
Cut cycle on recursive resource property types
langsamu Feb 21, 2024
096f6e8
Retain annotations at runtime
langsamu Feb 24, 2024
257d965
Cover resource definition
langsamu Feb 24, 2024
41ddb0a
Merge branch 'main' into declarative_wrapping
langsamu Feb 24, 2024
25b8cc7
Update version of new modules
langsamu Feb 24, 2024
18bf2e5
Style
langsamu Feb 24, 2024
a0b6988
Tidy wrapper processing environment
langsamu Feb 25, 2024
1e98804
Tidy manager test
langsamu Feb 25, 2024
bcd9f4f
Tidy temp E2E test
langsamu Feb 25, 2024
0684c44
Fix resource definition property method validation
langsamu Feb 25, 2024
de24e91
Validate that dataset graph methods are not void
langsamu Feb 25, 2024
92f3d38
Validate that graph resource methods are not void
langsamu Feb 25, 2024
0156da4
Reminder
langsamu Feb 25, 2024
fb9fd3a
Remove SPI reminder
langsamu Feb 25, 2024
a0381f5
Tidy
langsamu Feb 25, 2024
e13739e
Introduce dynamic cardinality
langsamu Feb 25, 2024
8499e2f
Extend and cover cardinality for singular accessors
langsamu Feb 27, 2024
9c5b510
Temporarily disable premature tests
langsamu Feb 27, 2024
9fde8ac
Rename 'interface' to 'definition'
langsamu Mar 2, 2024
e9365ee
Use predicates instead of selectors
langsamu Mar 2, 2024
1d7831b
Fix and suppress PMD warnings
langsamu Mar 2, 2024
27f992c
Tidy
langsamu Mar 3, 2024
6e39635
Introduce plural cardinality
langsamu Mar 3, 2024
ce5c0bc
Improve end-to-end test
langsamu Mar 3, 2024
8caa7c3
Merge branch 'main' into declarative_wrapping
langsamu Mar 3, 2024
18e34ef
Introducing mutation
langsamu Mar 9, 2024
dda9039
Overhaul definitions, extract resource property
langsamu Mar 9, 2024
f3369b0
Unify dataset properties
langsamu Mar 9, 2024
68ee19d
Unify graph properties
langsamu Mar 9, 2024
81fbe14
Tidy
langsamu Mar 9, 2024
21dae58
Simplify resource property
langsamu Mar 10, 2024
5246404
Describe value mapping complexity
langsamu Mar 10, 2024
c470b86
Tolerate variance in plural resource properties
langsamu Mar 10, 2024
a46bccc
Tolerate assignable return types for plural primitive resource proper…
langsamu Mar 12, 2024
a911366
Simplify resource definition
langsamu Mar 12, 2024
ff5171c
Handle plural complex resource properties
langsamu Mar 12, 2024
c5de4ba
Merge branch 'main' into declarative_wrapping
langsamu Mar 12, 2024
c801769
Validate plural complex resource properties
langsamu Mar 17, 2024
4fa2646
Handle all mutators
langsamu Mar 17, 2024
5c08deb
Handle plural mutators
langsamu Mar 17, 2024
cc91b05
Handle singular and forbid plural complex mutators
langsamu Mar 17, 2024
fc5f76e
Tidy
langsamu Mar 17, 2024
d865d42
Tidy
langsamu Mar 19, 2024
599fa3c
Support instantiating resource definitions
langsamu Mar 19, 2024
522e51e
Merge branch 'main' into declarative_wrapping
langsamu Mar 19, 2024
ffe506d
Expose resource factory
langsamu Mar 24, 2024
8cf9f83
Call super where adequate
langsamu Mar 24, 2024
f073cc8
Remove imports
langsamu Mar 24, 2024
e76802a
Reminder
langsamu Apr 6, 2024
1c524a0
Move things around
langsamu Apr 6, 2024
973c0d2
Move things around
langsamu Apr 6, 2024
ef63bcd
Tidy
langsamu Apr 6, 2024
778262a
Link to original from generated in javadoc
langsamu Apr 6, 2024
0f32600
Extract
langsamu Apr 6, 2024
8f59124
Tidy mutator implementor
langsamu Apr 6, 2024
06ec477
Tidy and cover manager resource creation
langsamu Apr 7, 2024
8958592
Merge branch 'refs/heads/main' into declarative_wrapping
langsamu Apr 7, 2024
5c39433
Move factories inside processor to hide wildcards
langsamu Apr 7, 2024
cfde5a4
Print error instead of throwing on implementor write failure
langsamu Apr 7, 2024
4466714
Dedicated exception
langsamu Apr 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions annotation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.inrupt.rdf</groupId>
<artifactId>inrupt-rdf-wrapping</artifactId>
<version>1.1.2-SNAPSHOT</version>
</parent>

<artifactId>inrupt-rdf-wrapping-annotation</artifactId>
<name>Inrupt RDF Wrapping - Annotation</name>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
<dependency>
<groupId>com.inrupt.rdf</groupId>
<artifactId>inrupt-rdf-wrapping-jena</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(TYPE)
@Retention(RUNTIME)
@Documented
public @interface Dataset {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(METHOD)
@Retention(RUNTIME)
@Documented
public @interface DatasetProperty {
String value() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(TYPE)
@Retention(RUNTIME)
@Documented
public @interface Graph {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static com.inrupt.rdf.wrapping.annotation.GraphProperty.Method.SUBJECT_OF;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(METHOD)
@Retention(RUNTIME)
@Documented
public @interface GraphProperty {
String[] value();

Method method() default SUBJECT_OF;

enum Method {
SUBJECT_OF("optionalFirstSubjectOfEither"),
OBJECT_OF("optionalFirstObjectOfEither"),
INSTANCE_OF("optionalFirstInstanceOfEither");

private final String methodName;

Method(final String methodName) {
this.methodName = methodName;
}

public String getMethodName() {
return methodName;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(TYPE)
@Retention(RUNTIME)
@Documented
public @interface Resource {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.rdf.wrapping.annotation;

import static com.inrupt.rdf.wrapping.annotation.ResourceProperty.Cardinality.ANY_OR_NULL;
import static com.inrupt.rdf.wrapping.annotation.ResourceProperty.NodeMapping.IDENTITY;
import static com.inrupt.rdf.wrapping.annotation.ResourceProperty.ValueMapping.AS;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Target(METHOD)
@Retention(RUNTIME)
@Documented
public @interface ResourceProperty {
String value();

// TODO: Rename
Cardinality cardinality() default ANY_OR_NULL;

ValueMapping valueMapping() default AS;

NodeMapping nodeMapping() default IDENTITY;

enum ValueMapping {
AS("as", true),
IRI_AS_STRING("iriAsString", false),
IRI_AS_URI("iriAsUri", false),
LITERAL_AS_BOOLEAN("literalAsBoolean", false),
LITERAL_AS_INSTANT("literalAsInstant", false),
LITERAL_AS_INTEGER_OR_NULL("literalAsIntegerOrNull", false),
LITERAL_AS_STRING("literalAsString", false);

private final String methodName;
private final boolean complex;

ValueMapping(final String methodName, final boolean complex) {
this.methodName = methodName;
this.complex = complex;
}

public String getMethodName() {
return methodName;
}

public boolean isComplex() {
return complex;
}
}

enum NodeMapping {
AS_STRING_LITERAL("asStringLiteral"),
AS_IRI("asIri"),
AS_TYPED_LITERAL("asTypedLiteral"),
IDENTITY("identity");

private final String methodName;

NodeMapping(final String methodName) {
this.methodName = methodName;
}

public String getMethodName() {
return methodName;
}
}

enum Cardinality {
ANY_OR_NULL("anyOrNull", false, false),

ANY_OR_THROW("anyOrThrow", false, false),

SINGLE_OR_NULL("singleOrNull", false, false),

SINGLE_OR_THROW("singleOrThrow", false, false),

OBJECT_ITERATOR("objectIterator", true, false),

OBJECTS_READ_ONLY("objectsReadOnly", true, false),

OBJECT_STREAM("objectStream", true, false),

OVERWRITE("overwrite", false, true),

OVERWRITE_NULLABLE("overwriteNullable", false, true),

ADD("add", false, true);

private final String methodName;
private final boolean plural;
private final boolean setter;

Cardinality(final String methodName, final boolean plural, final boolean setter) {
this.methodName = methodName;
this.plural = plural;
this.setter = setter;
}

public String getMethodName() {
return methodName;
}

public boolean isPlural() {
return plural;
}

public boolean isSetter() {
return setter;
}
}
}
Loading