Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
langsamu committed Aug 6, 2023
1 parent 03df564 commit f15dd4d
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import javax.tools.JavaFileObject;

@SupportedAnnotationTypes({
"com.inrupt.rdf.wrapping.declarative.annotations.Dataset",
"com.inrupt.rdf.wrapping.declarative.annotations.Graph",
"com.inrupt.rdf.wrapping.declarative.annotations.Resource"
"com.inrupt.rdf.wrapping.declarative.annotations.Dataset",
"com.inrupt.rdf.wrapping.declarative.annotations.Graph",
"com.inrupt.rdf.wrapping.declarative.annotations.Resource"
})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class Processor extends AbstractProcessor {
Expand All @@ -50,15 +50,22 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
}

for (TypeElement annotation : annotations) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, String.format("annotation [%s]", annotation), annotation);
processingEnv.getMessager().printMessage(
Diagnostic.Kind.NOTE,
String.format("annotation [%s]", annotation), annotation);

final Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotation);
for (Element annotatedElement : annotatedElements) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, String.format("annotatedElement [%s]", annotatedElement), annotatedElement);
processingEnv.getMessager().printMessage(
Diagnostic.Kind.NOTE,
String.format("annotatedElement [%s]", annotatedElement), annotatedElement);

final TypeElement annotatedType = (TypeElement) annotatedElement;
final String originalInterfaceName = annotatedType.getQualifiedName().toString();
final String originalBinaryName = processingEnv.getElementUtils().getBinaryName(annotatedType).toString();
final String originalBinaryName = processingEnv
.getElementUtils()
.getBinaryName(annotatedType)
.toString();
final String qualifiedName = originalBinaryName + "_$impl";
final int lastDot = originalBinaryName.lastIndexOf('.');
final String implementationClassName = qualifiedName.substring(lastDot + 1);
Expand Down Expand Up @@ -106,7 +113,10 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
return true;
}

private void printDataset(final String originalInterfaceName, final String implementationClassName, final PrintWriter out) {
private void printDataset(
final String originalInterfaceName,
final String implementationClassName,
final PrintWriter out) {
out.println("import javax.annotation.processing.Generated;");
out.println();
out.println("import org.apache.jena.sparql.core.DatasetGraph;");
Expand All @@ -131,7 +141,10 @@ private void printDataset(final String originalInterfaceName, final String imple
out.println("}");
}

private void printGraph(final String originalInterfaceName, final String implementationClassName, final PrintWriter out) {
private void printGraph(
final String originalInterfaceName,
final String implementationClassName,
final PrintWriter out) {
out.println("import javax.annotation.processing.Generated;");
out.println();
out.println("import org.apache.jena.graph.Graph;");
Expand All @@ -156,7 +169,10 @@ private void printGraph(final String originalInterfaceName, final String impleme
out.println("}");
}

private void printResource(final String originalInterfaceName, final String implementationClassName, final PrintWriter out) {
private void printResource(
final String originalInterfaceName,
final String implementationClassName,
final PrintWriter out) {
out.println("import com.inrupt.rdf.wrapping.jena.UriOrBlankFactory;");
out.println("import com.inrupt.rdf.wrapping.jena.WrapperResource;");
out.println();
Expand Down
16 changes: 14 additions & 2 deletions declarative/template/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</description>

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

<dependencies>
Expand All @@ -32,4 +32,16 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* 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.declarative.template;

import org.apache.jena.query.Dataset;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* 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.declarative.template;

// @Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public class ExampleNode1_$impl extends WrapperResource implements ExampleNode1 {
static final Implementation factory = new UriOrBlankFactory(ExampleNode1_$impl::new);

protected ExampleNode1_$impl(Node node, EnhGraph model) {
protected ExampleNode1_$impl(final Node node, final EnhGraph model) {
super(node, model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

// @Resource
public interface ExampleNode2 {
// @Property(predicate = "urn:example:p2", type = PropertyMappingTypes.anyOrNull, mapping = ValueMappingTypes.literalAsString)
// @Property(
// predicate = "urn:example:p2",
// type = PropertyMappingTypes.anyOrNull,
// mapping = ValueMappingTypes.literalAsString)
String getP2();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public class ExampleNode2_$impl extends WrapperResource implements ExampleNode2 {
static final Implementation factory = new UriOrBlankFactory(ExampleNode2_$impl::new);

protected ExampleNode2_$impl(Node node, EnhGraph model) {
protected ExampleNode2_$impl(final Node node, final EnhGraph model) {
super(node, model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.jena.rdf.model.Model;

/**
* A utility class that aids wrapper interfaces to find generated implementations
* A utility class that aids wrapper interfaces to find generated implementations.
*/
// TODO: Move to processor module
// TODO: Should this be SPI?
Expand All @@ -43,11 +43,11 @@ public static <T> T wrap(final Class<T> type, final Dataset original) {
return wrap(type, original, Dataset.class);
}

private static <T> T wrap(final Class<T> type, final Object original, Class<?> xtype) {
private static <T> T wrap(final Class<T> type, final Object original, final Class<?> xtype) {
final ClassLoader classLoader = type.getClassLoader();
final String implTypeName = type.getName() + "_$impl";

Class<? extends T> implClass;
final Class<? extends T> implClass;
try {
implClass = Class.forName(implTypeName, true, classLoader).asSubclass(type);
} catch (ClassNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
*/

/**
* Examples of wrapper interfaces and the implementations the Processor should generate from them
* Examples of wrapper interfaces and the implementations the Processor should generate from them.
*/
package com.inrupt.rdf.wrapping.declarative.template;
7 changes: 7 additions & 0 deletions declarative/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit f15dd4d

Please sign in to comment.