-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14164ee
commit 95f15b5
Showing
32 changed files
with
2,439 additions
and
29 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...processor/AnnotationWrapperProcessor.java → ...processor/AnnotationWrapperProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/AnnotationWrapperProcessorMessages.java → ...r/AnnotationWrapperProcessorMessages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...apperAnnotationProcessorMessagesTest.java → ...apperAnnotationProcessorMessagesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>aptk-constraint-api</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<parent> | ||
<groupId>io.toolisticon.aptk</groupId> | ||
<artifactId>extension-parent</artifactId> | ||
<version>0.22.12-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>aptk-constraint-api</name> | ||
|
||
|
||
<dependencies> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-library</artifactId> | ||
<version>${hamcrest.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.toolisticon.spiap</groupId> | ||
<artifactId>spiap-api</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
<build> | ||
|
||
<plugins> | ||
|
||
|
||
<plugin> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>enforce</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<requireMavenVersion> | ||
<version>[3.0.4,)</version> | ||
</requireMavenVersion> | ||
<requireJavaVersion> | ||
<version>${java.version}</version> | ||
</requireJavaVersion> | ||
<bannedDependencies> | ||
<searchTransitive>false</searchTransitive> | ||
<excludes> | ||
<exclude>*</exclude> | ||
</excludes> | ||
<includes> | ||
<include>*:*:*:*:test:*</include> | ||
<include>*:*:*:*:provided:*</include> | ||
</includes> | ||
</bannedDependencies> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
|
||
</plugins> | ||
|
||
</build> | ||
|
||
|
||
</project> |
35 changes: 35 additions & 0 deletions
35
...constraint-api/src/main/java/io/toolisticon/aptk/constraints/AnnotationConstraintSpi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.toolisticon.aptk.constraints; | ||
|
||
import io.toolisticon.spiap.api.Spi; | ||
import io.toolisticon.spiap.api.SpiServiceLocator; | ||
|
||
import javax.lang.model.element.AnnotationMirror; | ||
import javax.lang.model.element.Element; | ||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* A spi interface to process annotation constraints. | ||
*/ | ||
@Spi | ||
public interface AnnotationConstraintSpi { | ||
|
||
/** | ||
* Get the annotation supported by this spi implementation. | ||
* | ||
* @return the supported annotation | ||
*/ | ||
Class<? extends Annotation> getSupportedAnnotation(); | ||
|
||
|
||
|
||
/** | ||
* Checks constraint. | ||
* | ||
* @param annotatedElement The annotated element | ||
* @param annotationMirrorToCheck the annotation which has to be validated | ||
* @param constraintAnnotationMirror the constraint annotation used for checking | ||
* @param attributeNameToBeCheckedByConstraint the name of the annotation attribute with constraint or null if it is placed on annotation type | ||
*/ | ||
boolean checkConstraints(Element annotatedElement, AnnotationMirror annotationMirrorToCheck, AnnotationMirror constraintAnnotationMirror, String attributeNameToBeCheckedByConstraint); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
constraints/constraint-api/src/main/java/io/toolisticon/aptk/constraints/Constraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.toolisticon.aptk.constraints; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* | ||
* This annotation documents that an annotation declares a constraint. | ||
* | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(value = {ElementType.ANNOTATION_TYPE}) | ||
@Documented | ||
public @interface Constraint { | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...nts/constraint-api/src/main/java/io/toolisticon/aptk/constraints/ManualConstraintSpi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.toolisticon.aptk.constraints; | ||
|
||
import javax.lang.model.element.AnnotationMirror; | ||
import javax.lang.model.element.Element; | ||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* This spi is used to provide manual check for constraints. This can for example be checks for correct usage of the constraint annotations itself. | ||
* Additionally, it can be checks that aren*t available via constraint annotations | ||
* But | ||
*/ | ||
public interface ManualConstraintSpi { | ||
|
||
|
||
|
||
/** | ||
* Get the annotation supported by this spi implementation. | ||
* | ||
* @return the supported annotation | ||
*/ | ||
Class<? extends Annotation> getSupportedAnnotation(); | ||
|
||
|
||
/** | ||
* Do some manual checks for constraints. This can be checks if annotation constraint is used correctly | ||
* @param annotatedElement the annotated element | ||
* @param constraintAnnotationMirror the AnnotationMirror representing the constraint annotation | ||
*/ | ||
void checkManualConstraints(Element annotatedElement, AnnotationMirror constraintAnnotationMirror); | ||
|
||
|
||
|
||
|
||
} |
41 changes: 41 additions & 0 deletions
41
constraints/constraint-api/src/main/java/io/toolisticon/aptk/constraints/On.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.toolisticon.aptk.constraints; | ||
|
||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* The Target annotation is kind of fuzzy in some cases about where annotations might be used. | ||
* <p> | ||
* E.g. this is the case for TYPE, which allows you to use annotations on Classes, Interfaces, Enums and Annotations. | ||
* Another example is METHOD, which allows you to use annotations on methods or annotation attribute declarations. | ||
* <p> | ||
*/ | ||
@Documented | ||
@Constraint | ||
@Target(ElementType.ANNOTATION_TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface On { | ||
|
||
enum Location { | ||
PACKAGE, | ||
ANNOTATION_ATTRIBUTE, | ||
ANNOTATION, | ||
CLASS, | ||
INTERFACE, | ||
ENUM, | ||
METHOD, | ||
CONSTRUCTOR, | ||
PARAMETER, | ||
METHOD_PARAMETER, | ||
CONSTRUCTOR_PARAMETER, | ||
FIELD | ||
|
||
} | ||
|
||
Location[] value(); | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...traint-api/src/main/java/io/toolisticon/aptk/constraints/OnAnnotationAttributeOfType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.toolisticon.aptk.constraints; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Constraint | ||
@Target(ElementType.ANNOTATION_TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface OnAnnotationAttributeOfType { | ||
|
||
enum AttributeType { | ||
FLOAT, | ||
DOUBLE, | ||
INTEGER, | ||
LONG, | ||
STRING, | ||
CLASS, | ||
ENUM, | ||
ANNOTATION, | ||
FLOAT_ARRAY, | ||
DOUBLE_ARRAY, | ||
INTEGER_ARRAY, | ||
LONG_ARRAY, | ||
STRING_ARRAY, | ||
CLASS_ARRAY, | ||
ENUM_ARRAY, | ||
ANNOTATION_ARRAY, | ||
/** | ||
* Any kind of single value. | ||
*/ | ||
SINGLE_VALUE, | ||
/** | ||
* Any kind of array value. | ||
*/ | ||
ARRAY | ||
} | ||
|
||
AttributeType[] value(); | ||
|
||
} |
Oops, something went wrong.