├── .github ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── default.yml │ ├── default_oracle.yml │ ├── default_temurin.yml │ ├── dropStaging.yml │ ├── jacoco.yml │ └── release.yml ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── annotationwrapper ├── README.md ├── api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── annotationwrapper │ │ └── api │ │ ├── AnnotationWrapper.java │ │ ├── CustomCodeMethod.java │ │ └── CustomInterface.java ├── integrationtest │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── annotationwrapper │ │ │ └── test │ │ │ ├── EmbeddedAnnotation.java │ │ │ ├── ExampleTestAnnotation.java │ │ │ ├── TestDefaultsAnnotation.java │ │ │ ├── TestEnum.java │ │ │ ├── annotationonpackage │ │ │ ├── AutoDetectedCustomCodeClass.java │ │ │ ├── CustomCodeClass.java │ │ │ └── package-info.java │ │ │ └── annotationontype │ │ │ ├── AutoDetectedCustomCodeClass.java │ │ │ ├── CustomCodeClass.java │ │ │ └── PackagePlaceholder.java │ │ └── test │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── annotationwrapper │ │ └── test │ │ ├── annotationonpackage │ │ └── IntegrationTest.java │ │ └── annotationontype │ │ └── IntegrationTest.java ├── pom.xml └── processor │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── annotationwrapper │ │ │ └── processor │ │ │ ├── AnnotationWrapperProcessor.java │ │ │ └── AnnotationWrapperProcessorMessages.java │ └── resources │ │ └── AnnotationWrapper.tpl │ └── test │ ├── java │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── annotationwrapper │ │ └── processor │ │ ├── AnnotationWrapperProcessorTest.java │ │ └── WrapperAnnotationProcessorMessagesTest.java │ └── resources │ └── testcase │ ├── common │ ├── EmbeddedAnnotation.java │ ├── TestAnnotation.java │ └── TestEnum.java │ ├── withCustomCode │ ├── CustomCodeClass.java │ └── package-info.java │ ├── withCustomCodeButNonStaticMethod │ ├── CustomCodeClass.java │ └── package-info.java │ ├── withCustomCodeButNotVisibleMethod │ ├── CustomCodeClass.java │ └── package-info.java │ ├── withCustomCodeButWrongFirstParameter │ ├── CustomCodeClass.java │ └── package-info.java │ ├── withCustomCodeReferencingGeneratedType │ ├── CustomCodeClass.java │ ├── TestAnnotation2.java │ ├── otherTest │ │ ├── TestAnnotation3.java │ │ └── package-info.java │ └── package-info.java │ ├── withCustomInterface │ └── package-info.java │ ├── withWrappingOfEmbedded │ └── package-info.java │ └── withoutWrappingOfEmbedded │ └── package-info.java ├── aptk-api ├── pom.xml └── src │ └── main │ └── java │ └── io │ └── toolisticon │ └── aptk │ └── api │ └── AnnotationToClassMapper.java ├── common ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── common │ │ └── ToolingProvider.java │ └── test │ └── java │ └── io │ └── toolisticon │ └── aptk │ └── ToolingProviderTest.java ├── compilermessages ├── api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── compilermessage │ │ └── api │ │ ├── DeclareCompilerMessage.java │ │ ├── DeclareCompilerMessageCodePrefix.java │ │ └── DeclareCompilerMessages.java ├── integrationtest │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── compilermessage │ │ │ └── test │ │ │ ├── ByAnnotationAttribute.java │ │ │ └── OnClassAndNestedClass.java │ │ └── test │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── annotationwrapper │ │ └── annotationonpackage │ │ └── IntegrationTest.java ├── pom.xml └── processor │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── compilermessage │ │ │ └── processor │ │ │ ├── CompilerMessageProcessor.java │ │ │ ├── CompilerMessageProcessorMessages.java │ │ │ ├── CompilerMessageWrapperCustomCode.java │ │ │ └── package-info.java │ └── resources │ │ └── CompilerMessageEnum.tpl │ └── test │ ├── java │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── compilermessage │ │ └── processor │ │ └── CompilerMessageProcessorTest.java │ └── resources │ └── testcase │ ├── error_nonUniqueCode │ └── TestClass.java │ ├── error_nonUniqueEnumValueName │ └── TestClass.java │ └── happyPath_OnClass │ ├── RemoteTestClass.java │ └── TestClass.java ├── config ├── findbugs-excludes.xml └── sun_checks.xml ├── cute ├── pom.xml └── src │ └── main │ └── java │ └── io │ └── toolisticon │ └── aptk │ └── cute │ ├── APTKUnitTestProcessor.java │ ├── APTKUnitTestProcessorForTestingAnnotationProcessors.java │ ├── APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn.java │ └── APTKUnitTestProcessorWithoutPassIn.java ├── example ├── README.md ├── example-annotationprocessor │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── example │ │ │ └── annotationprocessor │ │ │ ├── ImplementsSpecificInterfaceCheckAnnotationProcessor.java │ │ │ └── MethodHasStringParameterAndVoidReturnTypeCheckAnnotationProcessor.java │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── example │ │ │ └── annotationprocessor │ │ │ ├── ImplementsSpecificInterfaceCheckAnnotationProcessorTest.java │ │ │ ├── ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest.java │ │ │ └── MethodWithOneStringParameterAndVoidReturnTypeProcessorTest.java │ │ └── resources │ │ └── testcases │ │ ├── implementsSpecificInterfaceCheckAnnotationProcessor │ │ ├── InvalidUsageTest.java │ │ ├── ValidUsageTest.java │ │ └── ValidUsageTestExtendsCase.java │ │ └── methodWithOneStringParameterAndVoidReturn │ │ ├── InvalidUsageNonStringParameter.java │ │ ├── InvalidUsageNonVoidReturnType.java │ │ └── ValidUsageTest.java ├── example-annotations │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── example │ │ └── annotations │ │ ├── ImplementsSpecificInterfaceCheckAnnotation.java │ │ ├── MethodWithOneStringParameterAndVoidReturnTypeAnnotation.java │ │ └── SpecificInterface.java ├── example-usecase │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── example │ │ └── usecase │ │ └── TestClass.java └── pom.xml ├── idea_aptk_codestyle.xml ├── integrationtest ├── java16 │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── integrationtest │ │ │ └── java16 │ │ │ ├── DummyClass.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── integrationtest │ │ └── java16 │ │ └── Java16Tests.java ├── java17 │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── integrationtest │ │ │ └── java17 │ │ │ ├── DummyClass.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── integrationtest │ │ └── java17 │ │ └── Java17Tests.java ├── java9 │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── integrationtest │ │ │ └── java9 │ │ │ ├── DummyClass.java │ │ │ └── package-info.java │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── toolisticon │ │ │ └── aptk │ │ │ └── integrationtest │ │ │ └── java9 │ │ │ └── ModuleElementWrapperTest.java │ │ └── resources │ │ └── testcases │ │ └── namedModule │ │ ├── MyProcessor.java │ │ ├── TestClass.java │ │ └── module-info.java └── pom.xml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── templating ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── templating │ │ ├── ModelPathResolver.java │ │ ├── NextDetectedBlockResult.java │ │ ├── ParseUtilities.java │ │ ├── TemplateProcessor.java │ │ ├── exceptions │ │ ├── InvalidElseIfException.java │ │ ├── InvalidExpressionResult.java │ │ ├── InvalidIncludeModelExpression.java │ │ ├── InvalidPathException.java │ │ └── MissingClosingTagException.java │ │ ├── expressions │ │ ├── AbstractSearchResult.java │ │ ├── Expression.java │ │ ├── ExpressionParser.java │ │ ├── operands │ │ │ ├── BooleanOperand.java │ │ │ ├── DoubleOperand.java │ │ │ ├── DynamicOperand.java │ │ │ ├── ExpressionOperand.java │ │ │ ├── InternalOperandTypeForCalculations.java │ │ │ ├── LongOperand.java │ │ │ ├── NullValueOperand.java │ │ │ ├── Operand.java │ │ │ ├── OperandFactory.java │ │ │ ├── OperandType.java │ │ │ ├── OperandTypeSearchResult.java │ │ │ ├── OperationResultOperand.java │ │ │ ├── ParsedOperand.java │ │ │ ├── StringOperand.java │ │ │ └── UnaryOperationWrapperOperand.java │ │ └── operations │ │ │ ├── OperationType.java │ │ │ ├── OperationTypeMode.java │ │ │ └── OperationTypeSearchResult.java │ │ └── templateblocks │ │ ├── ForTemplateBlock.java │ │ ├── IfTemplateBlock.java │ │ ├── IncludeTemplateBlock.java │ │ ├── PlainTextTemplateBlock.java │ │ ├── StaticTemplateBlock.java │ │ ├── TemplateBlock.java │ │ ├── TemplateBlockBinder.java │ │ ├── TemplateBlockType.java │ │ └── VariableTextTemplateBlock.java │ └── test │ ├── java │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── templating │ │ ├── ModelPathResolverTest.java │ │ ├── ParseUtilitiesTest.java │ │ ├── TemplateProcessorTest.java │ │ ├── expressions │ │ ├── ExpressionParserTest.java │ │ ├── ExpressionTest.java │ │ ├── operands │ │ │ ├── BooleanOperandTest.java │ │ │ ├── DoubleOperandTest.java │ │ │ ├── DynamicOperandTest.java │ │ │ ├── LongOperandTest.java │ │ │ ├── NullValueOperandTest.java │ │ │ ├── OperandFactoryTest.java │ │ │ ├── OperandTest.java │ │ │ ├── OperandTypeTest.java │ │ │ ├── StringOperandTest.java │ │ │ └── UnaryOperationWrapperOperandTest.java │ │ └── operations │ │ │ ├── OperationTest.java │ │ │ └── OperationTypeTest.java │ │ ├── templateblocks │ │ ├── ForTemplateBlockTest.java │ │ ├── IfTemplateBlockTest.java │ │ ├── IncludeTemplateBlockTest.java │ │ ├── PlainTextTemplateBlockTest.java │ │ ├── StaticTemplateBlockTest.java │ │ ├── TemplateBlockBinderTest.java │ │ ├── TemplateBlockTypeTest.java │ │ └── VariableTextTemplateBlockTest.java │ │ └── testclasses │ │ ├── TestClass1.java │ │ └── TestClass2.java │ └── resources │ ├── ComplexTemplateWithAllBlockTypes.expectedResult │ ├── ComplexTemplateWithAllBlockTypes.tpl │ ├── ComplexTemplateWithAllBlockTypesIncludedTemplate.tpl │ ├── ComplexTemplateWithControlBlock.expectedResult │ ├── ComplexTemplateWithControlBlock.tpl │ ├── GetControlBlockTemplateStringTestTemplate.expectedResult │ ├── GetControlBlockTemplateStringTestTemplate.tpl │ ├── IfStatementBlockType.expectedResult1 │ ├── IfStatementBlockType.expectedResult2 │ ├── IfStatementBlockType.expectedResult3 │ ├── IfStatementBlockType.tpl │ ├── IncludeTemplateBlockTest.expectedResult │ ├── IncludeTemplateBlockTest.tpl │ ├── IncludeTestWithModelAttribute.tpl │ ├── IncludeTestWithModelDefinitionInContent.tpl │ ├── MultipleVariableTextWithoutControlBlock.expectedResult │ ├── MultipleVariableTextWithoutControlBocks.tpl │ ├── ReadResourceToStringTest.txt │ ├── TestTemplateProcessorTemplateFile.tpl │ ├── TestTemplateWithDifferentIfStatements.expectedResult │ ├── TestTemplateWithDifferentIfStatments.tpl │ ├── TestTemplateWithDifferentVariableTextBlocks.expectedResult │ └── TestTemplateWithDifferentVariableTextBlocks.tpl └── tools ├── pom.xml ├── src ├── main │ └── java │ │ └── io │ │ └── toolisticon │ │ └── aptk │ │ └── tools │ │ ├── AbstractAnnotationProcessor.java │ │ ├── AnnotationToClassMapperHelper.java │ │ ├── AnnotationUtils.java │ │ ├── AnnotationValueUtils.java │ │ ├── BeanUtils.java │ │ ├── ElementUtils.java │ │ ├── FilerUtils.java │ │ ├── InterfaceUtils.java │ │ ├── MessagerUtils.java │ │ ├── ProcessingEnvironmentUtils.java │ │ ├── TypeMirrorWrapper.java │ │ ├── TypeUtils.java │ │ ├── Utilities.java │ │ ├── command │ │ ├── Command.java │ │ ├── CommandWithReturnType.java │ │ └── impl │ │ │ ├── GetAttributesCommand.java │ │ │ └── GetAttributesCommandWithInheritance.java │ │ ├── corematcher │ │ ├── AbstractBaseCoreMatcher.java │ │ ├── AptkCoreMatchers.java │ │ ├── CompilerMessage.java │ │ ├── CoreMatcherValidationMessages.java │ │ ├── CoreMatchers.java │ │ ├── ExclusiveCriteriaCoreMatcher.java │ │ ├── ExclusiveCriteriaElementBasedCoreMatcher.java │ │ ├── ImplicitCoreMatcher.java │ │ ├── ImplicitElementBasedCoreMatcher.java │ │ ├── InclusiveCharacteristicElementBasedCoreMatcher.java │ │ ├── InclusiveCriteriaCoreMatcher.java │ │ ├── IsCoreMatcher.java │ │ ├── IsElementBasedCoreMatcher.java │ │ ├── PlainValidationMessage.java │ │ ├── ValidationMessage.java │ │ └── package-info.java │ │ ├── filter │ │ ├── ExclusiveCriteriaElementFilter.java │ │ ├── ImplicitFilter.java │ │ ├── InclusiveCriteriaElementFilter.java │ │ ├── impl │ │ │ └── CriteriaElementFilterImpl.java │ │ └── package-info.java │ │ ├── fluentfilter │ │ ├── FluentElementFilter.java │ │ ├── TransitionFilters.java │ │ ├── impl │ │ │ ├── ChildElementsTransitionFilter.java │ │ │ ├── ElementBasedTransitionFilter.java │ │ │ ├── ParentElementTransitionFilter.java │ │ │ ├── RemoveDuplicatesTransitionFilter.java │ │ │ ├── SuperTypesTransitionFilter.java │ │ │ └── TransitionFilter.java │ │ └── package-info.java │ │ ├── fluentvalidator │ │ ├── FluentElementValidator.java │ │ ├── impl │ │ │ ├── FluentValidatorMessage.java │ │ │ ├── FluentValidatorState.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── generators │ │ ├── FileObjectSimpleWriter.java │ │ ├── SimpleJavaWriter.java │ │ ├── SimpleKotlinWriter.java │ │ ├── SimpleResourceReader.java │ │ ├── SimpleResourceWriter.java │ │ ├── SimpleWriter.java │ │ └── package-info.java │ │ ├── generics │ │ ├── GenericType.java │ │ ├── GenericTypeKind.java │ │ ├── GenericTypeParameter.java │ │ ├── GenericTypeWildcard.java │ │ └── package-info.java │ │ ├── matcher │ │ ├── BaseMatcher.java │ │ ├── CriteriaMatcher.java │ │ ├── ImplicitMatcher.java │ │ ├── impl │ │ │ ├── ByAnnotationMatcher.java │ │ │ ├── ByElementKindMatcher.java │ │ │ ├── ByGenericTypeMatcher.java │ │ │ ├── ByModifierMatcher.java │ │ │ ├── ByNameMatcher.java │ │ │ ├── ByNameRegexMatcher.java │ │ │ ├── ByNestingKindMatcher.java │ │ │ ├── ByNumberOfParametersMatcher.java │ │ │ ├── ByPackageNameMatcher.java │ │ │ ├── ByParameterTypeFqnMatcher.java │ │ │ ├── ByParameterTypeMatcher.java │ │ │ ├── ByParameterTypeMirrorMatcher.java │ │ │ ├── ByQualifiedNameMatcher.java │ │ │ ├── ByQualifiedNameRegexMatcher.java │ │ │ ├── ByRawTypeFqnMatcher.java │ │ │ ├── ByRawTypeMatcher.java │ │ │ ├── ByReturnTypeFqnMatcher.java │ │ │ ├── ByReturnTypeMatcher.java │ │ │ ├── ByReturnTypeMirrorMatcher.java │ │ │ ├── HasNoParametersMatcher.java │ │ │ ├── HasNoThrownTypesMatcher.java │ │ │ ├── HasPublicNoargConstructorMatcher.java │ │ │ ├── HasVoidReturnTypeMatcher.java │ │ │ ├── IsAnnotationTypeMatcher.java │ │ │ ├── IsAssignableToFqnMatcher.java │ │ │ ├── IsAssignableToMatcher.java │ │ │ ├── IsAssignableToTypeMirrorMatcher.java │ │ │ ├── IsAttributeFieldMatcher.java │ │ │ ├── IsClassMatcher.java │ │ │ ├── IsConstructorMatcher.java │ │ │ ├── IsEnumMatcher.java │ │ │ ├── IsExecutableElementMatcher.java │ │ │ ├── IsFieldMatcher.java │ │ │ ├── IsGetterMethodMatcher.java │ │ │ ├── IsInterfaceMatcher.java │ │ │ ├── IsMethodMatcher.java │ │ │ ├── IsPackageElementMatcher.java │ │ │ ├── IsPackageMatcher.java │ │ │ ├── IsParameterMatcher.java │ │ │ ├── IsRecordMatcher.java │ │ │ ├── IsSetterMethodMatcher.java │ │ │ ├── IsTypeElementMatcher.java │ │ │ ├── IsTypeEqualFqnMatcher.java │ │ │ ├── IsTypeEqualMatcher.java │ │ │ ├── IsTypeMatcher.java │ │ │ ├── IsVariableElementMatcher.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── validator │ │ ├── AbstractBaseValidator.java │ │ ├── ExclusiveCriteriaElementValidator.java │ │ ├── ImplicitValidator.java │ │ ├── InclusiveCriteriaElementValidator.java │ │ ├── impl │ │ │ └── CriteriaElementValidatorImpl.java │ │ └── package-info.java │ │ └── wrapper │ │ ├── AnnotationMirrorWrapper.java │ │ ├── AnnotationValueWrapper.java │ │ ├── CompileMessageWriter.java │ │ ├── ElementWrapper.java │ │ ├── ElementWrapperValidator.java │ │ ├── ElementWrapperValidatorInterface.java │ │ ├── ExecutableElementWrapper.java │ │ ├── ModuleElementWrapper.java │ │ ├── PackageElementWrapper.java │ │ ├── RecordComponentElementWrapper.java │ │ ├── TypeElementWrapper.java │ │ ├── TypeParameterElementWrapper.java │ │ └── VariableElementWrapper.java └── test │ ├── java │ └── io │ │ └── toolisticon │ │ └── aptk │ │ ├── tools │ │ ├── AbstractAnnotationProcessorTest.java │ │ ├── AbstractUnitTestAnnotationProcessorClass.java │ │ ├── AnnotationToClassMapperHelperTest.java │ │ ├── AnnotationUtilsTest.java │ │ ├── AnnotationValueUtilsTest.java │ │ ├── BeanUtilsTest.java │ │ ├── DummyValidatorMessage.java │ │ ├── ElementUtilsTest.java │ │ ├── ElementUtils_AccessEnclosedElementsTest.java │ │ ├── ElementUtils_AccessEnclosingElementsTest.java │ │ ├── ElementUtils_AccessTypeHierarchyTest.java │ │ ├── ElementUtils_CastElementTest.java │ │ ├── ElementUtils_CheckKindOfElementTest.java │ │ ├── ElementUtils_CheckModifierOfElementTest.java │ │ ├── FilerUtilsTest.java │ │ ├── FilterTestAnnotation1.java │ │ ├── FilterTestAnnotation2.java │ │ ├── FluentElementFilterTest.java │ │ ├── InterfaceUtilsTest.java │ │ ├── IsRepeatable.java │ │ ├── IsRepeatableWrapper.java │ │ ├── MessagerUtilsTest.java │ │ ├── ProcessEnvironmentUtilsTest.java │ │ ├── TestCoreMatcherFactory.java │ │ ├── TestMatchers.java │ │ ├── TypeMirrorWrapperTest.java │ │ ├── TypeUtilsTest.java │ │ ├── TypeUtils_CheckTypeKindTest.java │ │ ├── TypeUtils_GenericsTest.java │ │ ├── UtilitiesTest.java │ │ ├── annotationutilstestclasses │ │ │ ├── ClassArrayAttributeAnnotation.java │ │ │ ├── ClassAttributeAnnotation.java │ │ │ ├── DefaultValueAnnotation.java │ │ │ └── NoAttributeAnnotation.java │ │ ├── annotationvalueutilstestclasses │ │ │ └── AnnotationValueTestAnnotation.java │ │ ├── command │ │ │ └── impl │ │ │ │ ├── GetAttributesCommandTest.java │ │ │ │ └── GetAttributesCommandWithInheritanceTest.java │ │ ├── filter │ │ │ ├── ImplicitFilterTest.java │ │ │ └── InclusiveCriteriaElementFilterTest.java │ │ ├── fluentfilter │ │ │ ├── FluentElementFilterTest.java │ │ │ └── impl │ │ │ │ ├── ChildElementsTransitionFilterTest.java │ │ │ │ ├── ParentElementTransitionFilterTest.java │ │ │ │ ├── RemoveDuplicatesTransitionFilterTest.java │ │ │ │ └── SuperTypesTransitionFilterTest.java │ │ ├── fluentvalidator │ │ │ ├── FluentElementValidatorTest.java │ │ │ └── impl │ │ │ │ ├── FluentValidatorMessageTest.java │ │ │ │ └── FluentValidatorStateTest.java │ │ ├── generators │ │ │ ├── FileObjectUtilsTestAnnotation.java │ │ │ ├── FileObjectUtilsTestAnnotationProcessor.java │ │ │ ├── SimpleKotlinWriterTest.java │ │ │ ├── SimpleResourceReaderTest.java │ │ │ └── SimpleResourceWriterTest.java │ │ ├── internal │ │ │ └── UtilitiesTest.java │ │ ├── matcher │ │ │ └── impl │ │ │ │ ├── ByAnnotationMatcherTest.java │ │ │ │ ├── ByElementKindMatcherTest.java │ │ │ │ ├── ByGenericTypeMatcherTest.java │ │ │ │ ├── ByModifierMatcherTest.java │ │ │ │ ├── ByNameMatcherTest.java │ │ │ │ ├── ByNameRegexMatcherTest.java │ │ │ │ ├── ByNestingKindMatcherTest.java │ │ │ │ ├── ByNumberOfParametersMatcherTest.java │ │ │ │ ├── ByPackageNameMatcherTest.java │ │ │ │ ├── ByParameterTypeFqnMatcherTest.java │ │ │ │ ├── ByParameterTypeMatcherTest.java │ │ │ │ ├── ByParameterTypeMirrorMatcherTest.java │ │ │ │ ├── ByQualifiedNameMatcherTest.java │ │ │ │ ├── ByQualifiedNameRegexMatcherTest.java │ │ │ │ ├── ByRawTypeFqnMatcherTest.java │ │ │ │ ├── ByRawTypeMatcherTest.java │ │ │ │ ├── ByReturnTypeFqnMatcherTest.java │ │ │ │ ├── ByReturnTypeMatcherTest.java │ │ │ │ ├── ByReturnTypeMirrorMatcherTest.java │ │ │ │ ├── HasNoParameterMatcherTest.java │ │ │ │ ├── HasNoThrownTypesMatcherTest.java │ │ │ │ ├── HasPublicNoargConstructorMatcherTest.java │ │ │ │ ├── HasVoidReturnTypeMatcherTest.java │ │ │ │ ├── IsAnnotationTypeMatcherTest.java │ │ │ │ ├── IsAssignableToFqnMatcherTest.java │ │ │ │ ├── IsAssignableToMatcherTest.java │ │ │ │ ├── IsAssignableToTypeMirrorMatcherTest.java │ │ │ │ ├── IsAttributeFieldMatcherTest.java │ │ │ │ ├── IsClassMatcherTest.java │ │ │ │ ├── IsConstructorMatcherTest.java │ │ │ │ ├── IsEnumMatcherTest.java │ │ │ │ ├── IsExecutableElementMatcherTest.java │ │ │ │ ├── IsFieldMatcherTest.java │ │ │ │ ├── IsGetterMethodMatcherTest.java │ │ │ │ ├── IsInterfaceMatcherTest.java │ │ │ │ ├── IsMethodMatcherTest.java │ │ │ │ ├── IsPackageElementMatcherTest.java │ │ │ │ ├── IsPackageMatcherTest.java │ │ │ │ ├── IsParameterMatcherTest.java │ │ │ │ ├── IsSetterMethodMatcherTest.java │ │ │ │ ├── IsTypeElementMatcherTest.java │ │ │ │ ├── IsTypeEqualFqnMatcherTest.java │ │ │ │ ├── IsTypeEqualMatcherTest.java │ │ │ │ ├── IsVariableElementMatcherTest.java │ │ │ │ └── ParameterTypeFqnMatcherTest.java │ │ ├── validator │ │ │ ├── AnnotationValidatorTest.java │ │ │ ├── GenericMatcherTest.java │ │ │ ├── ModifierValidatorTest.java │ │ │ └── impl │ │ │ │ └── CriteriaElementValidatorImplTest.java │ │ └── wrapper │ │ │ ├── AnnotationMirrorWrapperTest.java │ │ │ ├── AnnotationValueWrapperTest.java │ │ │ ├── ElementWrapperTest.java │ │ │ ├── ExecutableElementWrapperTest.java │ │ │ ├── ModulesElementWrapperTest.java │ │ │ ├── PackageElementWrapperTest.java │ │ │ ├── TypeElementWrapperTest.java │ │ │ ├── TypeParameterElementWrapperTest.java │ │ │ └── VariableElementWrapperTest.java │ │ └── validators │ │ └── FluentElementValidatorTest.java │ └── resources │ ├── AnnotationClassAttributeTestClass.java │ ├── AnnotationProcessorTestClass.java │ ├── AnnotationProcessorUnitTestClassInternal.java │ ├── AnnotationValueUtilsTestClass.java │ ├── GenericsTestClass.java │ ├── mockito-extensions │ └── org.mockito.plugins.MockMaker │ ├── testcases.beanutils │ ├── DefaultNoargConstructorTest.java │ ├── ExplicitNoargConstructorTest.java │ ├── ExplicitNoargConstructorTest2.java │ ├── FieldLevelTestcases.java │ └── TypeHierarchyTestClass.java │ ├── testcases.commands │ ├── GetAttributesCommandTestClass.java │ └── GetAttributesCommandWithInheritanceTestClass.java │ ├── testcases.matchers.hasnoargsconstructormatcher │ ├── LombokNoArgsConstructorAnnotation.java │ └── LombokNoConstructorWithAllArgsConstructorAnnotation.java │ └── testcases │ └── generators │ ├── FilerUtilsTestClass.java │ ├── expectedResult.txt │ └── testTemplate.tpl └── tmp ├── AnnotationValidatorTest.java ├── FluentElementValidatorTest.java ├── FluentModifierElementValidatorTest.java ├── FluentTypeElementValidatorTest.java ├── FluentValidatorTest.java ├── GenericMatcherTest.java ├── ModifierValidatorTest.java ├── TypeElementCharacteristicMatcherTest.java └── ValidatorTest.java /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: org.mockito:mockito-core 11 | versions: 12 | - 3.7.7 13 | - 3.8.0 14 | - dependency-name: org.projectlombok:lombok 15 | versions: 16 | - 1.18.18 17 | - dependency-name: org.codehaus.mojo:animal-sniffer-maven-plugin 18 | versions: 19 | - "1.19" 20 | - dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin 21 | versions: 22 | - 3.1.1 23 | -------------------------------------------------------------------------------- /.github/workflows/default.yml: -------------------------------------------------------------------------------- 1 | name: default 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '**/*' 8 | - '!master' 9 | 10 | jobs: 11 | build: 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ ubuntu-latest,macos-latest,windows-latest ] 16 | java: [ '8', '11', '17', '21' ] 17 | 18 | steps: 19 | - name: Checkout Code 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up JDK ${{ matrix.java }} 23 | uses: actions/setup-java@v4 24 | with: 25 | distribution: 'zulu' 26 | java-version: ${{ matrix.java }} 27 | cache: 'maven' 28 | 29 | 30 | - name: Prepare mvnw 31 | run: chmod +x ./mvnw 32 | 33 | - name: Build 34 | run: ./mvnw clean package 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /.github/workflows/default_oracle.yml: -------------------------------------------------------------------------------- 1 | name: default_oracle 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '**/*' 8 | - '!master' 9 | 10 | jobs: 11 | build: 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ ubuntu-latest,macos-latest,windows-latest ] 16 | java: [ '17', '21' ] 17 | 18 | steps: 19 | - name: Checkout Code 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up JDK ${{ matrix.java }} 23 | uses: actions/setup-java@v4 24 | with: 25 | distribution: 'oracle' 26 | java-version: ${{ matrix.java }} 27 | cache: 'maven' 28 | 29 | 30 | - name: Prepare mvnw 31 | run: chmod +x ./mvnw 32 | 33 | - name: Build 34 | run: ./mvnw clean package 35 | 36 | -------------------------------------------------------------------------------- /.github/workflows/default_temurin.yml: -------------------------------------------------------------------------------- 1 | name: default_temurin 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '**/*' 8 | - '!master' 9 | 10 | jobs: 11 | build: 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ ubuntu-latest,macos-latest,windows-latest ] 16 | java: [ '11', '17', '21' ] 17 | 18 | steps: 19 | - name: Checkout Code 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up JDK ${{ matrix.java }} 23 | uses: actions/setup-java@v4 24 | with: 25 | distribution: 'temurin' 26 | java-version: ${{ matrix.java }} 27 | cache: 'maven' 28 | 29 | 30 | - name: Prepare mvnw 31 | run: chmod +x ./mvnw 32 | 33 | - name: Build 34 | run: ./mvnw clean package 35 | 36 | -------------------------------------------------------------------------------- /.github/workflows/dropStaging.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Drop Staging Repository 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Allows you to run this workflow manually from the Actions tab 8 | workflow_dispatch: 9 | 10 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 11 | jobs: 12 | # This workflow contains a single job called "build" 13 | build: 14 | # The type of runner that the job will run on 15 | runs-on: ubuntu-latest 16 | 17 | # Steps represent a sequence of tasks that will be executed as part of the job 18 | steps: 19 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 20 | - uses: actions/checkout@v4 21 | 22 | # Setup JDK and Maven 23 | - name: Set up JDK 9 24 | uses: actions/setup-java@v4 25 | with: 26 | distribution: 'zulu' 27 | java-version: 17 28 | cache: 'maven' 29 | server-id: sonatype-nexus-staging 30 | server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central 31 | server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central 32 | 33 | # Drop staging repository 34 | - name: drop staging 35 | run: ./mvnw nexus-staging:drop -DstagingDescription="Drop staging" 36 | env: 37 | OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 38 | OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 39 | -------------------------------------------------------------------------------- /.github/workflows/jacoco.yml: -------------------------------------------------------------------------------- 1 | name: jacoco 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '**/*' 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout code 16 | uses: actions/checkout@v4 17 | 18 | - name: Set up JDK 17 19 | uses: actions/setup-java@v4 20 | with: 21 | distribution: 'zulu' 22 | java-version: 17 23 | cache: 'maven' 24 | 25 | 26 | - name: Prepare mvnw 27 | run: chmod +x ./mvnw 28 | 29 | - name: Build 30 | run: ./mvnw verify jacoco:report-aggregate -B -q 31 | 32 | - name: Upload coverage to Codecov 33 | uses: codecov/codecov-action@v2 34 | with: 35 | token: ${{secrets.CODECOV_TOKEN}} 36 | files: target/site/jacoco-aggregate/jacoco.xml 37 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release_on_master 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout Code 14 | uses: actions/checkout@v4 15 | 16 | # Get GPG private key into GPG 17 | - name: Import GPG Owner Trust 18 | run: echo ${{ secrets.GPG_OWNERTRUST }} | base64 --decode | gpg --import-ownertrust 19 | - name: Import GPG key 20 | run: echo ${{ secrets.GPG_SECRET_KEYS }} | base64 --decode | gpg --import --no-tty --batch --yes 21 | 22 | # Setup JDK and Maven 23 | - name: Set up JDK 17 24 | uses: actions/setup-java@v4 25 | with: 26 | distribution: 'zulu' 27 | java-version: 17 28 | cache: 'maven' 29 | server-id: sonatype-nexus-staging 30 | server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central 31 | server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central 32 | 33 | - name: Prepare mvnw 34 | run: chmod +x ./mvnw 35 | 36 | - name: Build 37 | run: ./mvnw clean package 38 | 39 | - name: Deploy a new version to central 40 | run: ./mvnw clean install javadoc:jar source:jar deploy -B -DskipTests -Prelease -Dgpg.keyname=${{secrets.GPG_KEYNAME}} -Dgpg.passphrase="${{secrets.GPG_PASSPHRASE}}" 41 | env: 42 | OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 43 | OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build and Release Folders 2 | target 3 | .settings 4 | .project 5 | .classpath 6 | *.iml 7 | .idea 8 | atlassian-ide-plugin.xml 9 | **/dependency-reduced-pom.xml 10 | **/.factorypath 11 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toolisticon/aptk/00148fc03a2e6c5dfb5ee541bec3af78f5b91686/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 TOOListicon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /annotationwrapper/api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | aptk-annotationwrapper-api 6 | jar 7 | 8 | 9 | io.toolisticon.aptk 10 | aptk-annotationwrapper-parent 11 | 0.30.3-SNAPSHOT 12 | 13 | 14 | aptk-annotationwrapper-api 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /annotationwrapper/api/src/main/java/io/toolisticon/aptk/annotationwrapper/api/AnnotationWrapper.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.api; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Annotation to create a wrapper class for an annotation. 12 | * The wrapper 13 | */ 14 | @Target({ElementType.PACKAGE, ElementType.TYPE}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | public @interface AnnotationWrapper { 18 | /** 19 | * The annotations to create wrappers for. 20 | * 21 | * @return 22 | */ 23 | Class[] value(); 24 | 25 | /** 26 | * Adds a custom interface to the wrapper. 27 | * 28 | * @return 29 | */ 30 | CustomInterface[] customInterfaces() default {}; 31 | 32 | /** 33 | * Bind custom code into the api. 34 | * 35 | * @return 36 | */ 37 | Class[] bindCustomCode() default {}; 38 | 39 | /** 40 | * Configures to generate wrappers for all embedded annotations as well. 41 | * Defaults to true. 42 | * 43 | * @return 44 | */ 45 | boolean automaticallyWrapEmbeddedAnnotations() default true; 46 | 47 | /** 48 | * Configures to use public visibility for all wrappers. 49 | * Package private visibility will be used, if set to false 50 | * Defaults to false. 51 | * 52 | * @return 53 | */ 54 | boolean usePublicVisibility() default false; 55 | } 56 | -------------------------------------------------------------------------------- /annotationwrapper/api/src/main/java/io/toolisticon/aptk/annotationwrapper/api/CustomCodeMethod.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.api; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Marks method to be included as custom code to wrapper api. 12 | *

13 | * Annotated methods must be non private, static and their first parameter must match the Annotation wrapper type to which the method should be bound. 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | public @interface CustomCodeMethod { 19 | /** The annotation to which the code method should be bound with. */ 20 | Class value(); 21 | } 22 | -------------------------------------------------------------------------------- /annotationwrapper/api/src/main/java/io/toolisticon/aptk/annotationwrapper/api/CustomInterface.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.api; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Adds custom interfaces to AnnotationWrapper 12 | */ 13 | @Target(ElementType.ANNOTATION_TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | public @interface CustomInterface { 17 | 18 | /** 19 | * Annotation type. 20 | * @return 21 | */ 22 | Class annotationToWrap(); 23 | 24 | /** 25 | * Interfaces to apply 26 | * @return 27 | */ 28 | Class[] interfacesToApply(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/EmbeddedAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface EmbeddedAnnotation { 8 | long value(); 9 | } 10 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/ExampleTestAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target(ElementType.TYPE) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface ExampleTestAnnotation { 13 | 14 | // single value attributes 15 | 16 | String stringAttribute(); 17 | 18 | char charAttribute() default 'X'; 19 | 20 | int intAttribute() default 0; 21 | 22 | long longAttribute(); 23 | 24 | float floatAttribute() default 0.0f; 25 | 26 | double doubleAttribute(); 27 | 28 | short shortAttribute() default 0; 29 | 30 | byte byteAttribute() default 0; 31 | 32 | boolean booleanAttribute() default false; 33 | 34 | Class typeAttribute(); 35 | 36 | TestEnum enumAttribute(); 37 | 38 | EmbeddedAnnotation annotationAttribute(); 39 | 40 | // Array based attributes 41 | 42 | String[] stringArrayAttribute() default {}; 43 | 44 | char[] charArrayAttribute() default {}; 45 | 46 | int[] intArrayAttribute() default {}; 47 | 48 | long[] longArrayAttribute() default {}; 49 | 50 | float[] floatArrayAttribute() default {}; 51 | 52 | double[] doubleArrayAttribute() default {}; 53 | 54 | boolean[] booleanArrayAttribute() default {}; 55 | 56 | short[] shortArrayAttribute() default {}; 57 | 58 | byte[] byteArrayAttribute() default {}; 59 | 60 | TestEnum[] enumArrayAttribute(); 61 | 62 | Class[] typeArrayAttribute(); 63 | 64 | EmbeddedAnnotation[] annotationArrayAttribute(); 65 | 66 | } -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/TestDefaultsAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface TestDefaultsAnnotation { 11 | 12 | String withDefault() default "default"; 13 | 14 | String withoutDefault() default "notDefault"; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/TestEnum.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test; 2 | 3 | public enum TestEnum { 4 | ONE, TWO, THREE; 5 | } -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/AutoDetectedCustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 5 | 6 | public class AutoDetectedCustomCodeClass { 7 | 8 | @CustomCodeMethod(ExampleTestAnnotation.class) 9 | public static String autoDetectedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 10 | testAnnotationWrapper.enumAttribute(); 11 | return "it worked : " + firstArg; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(ExampleTestAnnotation.class) 9 | public static String forwardedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 10 | testAnnotationWrapper.enumAttribute(); 11 | return "it worked : " + firstArg; 12 | } 13 | 14 | @CustomCodeMethod(ExampleTestAnnotation.class) 15 | public static void forwardedMethodWithNoReturnValue(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 16 | testAnnotationWrapper.enumAttribute(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper( 2 | value = {ExampleTestAnnotation.class, TestDefaultsAnnotation.class}, 3 | bindCustomCode = {CustomCodeClass.class}, 4 | automaticallyWrapEmbeddedAnnotations = true) 5 | package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; 6 | 7 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 8 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 9 | import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/AutoDetectedCustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test.annotationontype; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 5 | 6 | public class AutoDetectedCustomCodeClass { 7 | 8 | @CustomCodeMethod(ExampleTestAnnotation.class) 9 | public static String autoDetectedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 10 | testAnnotationWrapper.enumAttribute(); 11 | return "it worked : " + firstArg; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test.annotationontype; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(ExampleTestAnnotation.class) 9 | public static String forwardedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 10 | testAnnotationWrapper.enumAttribute(); 11 | return "it worked : " + firstArg; 12 | } 13 | 14 | @CustomCodeMethod(ExampleTestAnnotation.class) 15 | public static void forwardedMethodWithNoReturnValue(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { 16 | testAnnotationWrapper.enumAttribute(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/PackagePlaceholder.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.test.annotationontype; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 4 | import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; 5 | import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; 6 | 7 | 8 | @AnnotationWrapper( 9 | value = {ExampleTestAnnotation.class, TestDefaultsAnnotation.class}, 10 | bindCustomCode = {CustomCodeClass.class}, 11 | automaticallyWrapEmbeddedAnnotations = true) 12 | 13 | public class PackagePlaceholder { 14 | } 15 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/main/java/io/toolisticon/aptk/annotationwrapper/processor/AnnotationWrapperProcessorMessages.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.processor; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.tools.corematcher.ValidationMessage; 5 | 6 | public enum AnnotationWrapperProcessorMessages implements ValidationMessage { 7 | 8 | ERROR_CUSTOMCODEMETHOD_REFERENCES_NO_WRAPPER("ANNOTATION_WRAPPER_ERROR_001", CustomCodeMethod.class.getSimpleName().toString() + " annotated methods first parameter must be a known annotation wrapper but is ${0}"), 9 | ERROR_CANT_CREATE_WRAPPER("ANNOTATION_WRAPPER_ERROR_001", "Can't create wrapper class for Annotation ${0}"), 10 | ERROR_FIRST_PARAMETER_OF_CUSTOM_CODE_METHOD_MUST_BE_WRAPPER_TYPE("ANNOTATION_WRAPPER_ERROR_001", "The first parameter of a custom code method for an annotation wrapper must be of the annotation wrapper type '${0}' but has is '${1}'"); 11 | 12 | /** 13 | * the message code. 14 | */ 15 | private final String code; 16 | /**s 17 | * the message text. 18 | */ 19 | private final String message; 20 | 21 | /** 22 | * Constructor. 23 | * 24 | * @param code the message code 25 | * @param message the message text 26 | */ 27 | AnnotationWrapperProcessorMessages(String code, String message) { 28 | this.code = code; 29 | this.message = message; 30 | } 31 | 32 | /** 33 | * Gets the code of the message. 34 | * 35 | * @return the message code 36 | */ 37 | public String getCode() { 38 | return this.code; 39 | } 40 | 41 | /** 42 | * Gets the message text. 43 | * 44 | * @return the message text 45 | */ 46 | public String getMessage() { 47 | return message; 48 | } 49 | 50 | 51 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/java/io/toolisticon/aptk/annotationwrapper/processor/WrapperAnnotationProcessorMessagesTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.annotationwrapper.processor; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for {@link AnnotationWrapperProcessorMessages}. 9 | *

10 | */ 11 | public class WrapperAnnotationProcessorMessagesTest { 12 | 13 | @Test 14 | public void test_enum() { 15 | 16 | MatcherAssert.assertThat(AnnotationWrapperProcessorMessages.ERROR_CANT_CREATE_WRAPPER.getCode(), Matchers.is("ANNOTATION_WRAPPER_ERROR_001")); 17 | MatcherAssert.assertThat(AnnotationWrapperProcessorMessages.ERROR_CANT_CREATE_WRAPPER.getMessage(), Matchers.notNullValue()); 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/common/EmbeddedAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface EmbeddedAnnotation { 8 | long value(); 9 | } 10 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/common/TestAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target(ElementType.TYPE) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface TestAnnotation { 13 | 14 | char charAttribute() default 'X'; 15 | 16 | String stringAttribute(); 17 | 18 | int intAttribute(); 19 | 20 | long longAttribute(); 21 | 22 | float floatAttribute() default 0.0f; 23 | 24 | double doubleAttribute(); 25 | 26 | boolean booleanAttribute() default false; 27 | 28 | Class typeAttribute(); 29 | 30 | TestEnum enumAttribute(); 31 | 32 | EmbeddedAnnotation annotationAttribute(); 33 | 34 | 35 | int[] intArrayAttribute() default{}; 36 | long[] longArrayAttribute() default{}; 37 | float[] floatArrayAttribute() default{}; 38 | double[] doubleArrayAttribute() default{}; 39 | boolean[] booleanArrayAttribute() default{}; 40 | char[] charArrayAttribute() default {}; 41 | 42 | String[] stringArrayAttribute() default {}; 43 | 44 | TestEnum[] enumArrayAttribute(); 45 | 46 | Class[] typeArrayAttribute(); 47 | 48 | EmbeddedAnnotation[] annotationArrayAttribute(); 49 | 50 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/common/TestEnum.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | public enum TestEnum { 4 | ONE, TWO, THREE; 5 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCode/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(TestAnnotation.class) 9 | public static String shouldWork(TestAnnotationWrapper testAnnotationWrapper, String arg1) { 10 | return "yes " + arg1; 11 | } 12 | 13 | @CustomCodeMethod(TestAnnotation.class) 14 | public static void shouldWorkWithVoidReturnValue(TestAnnotationWrapper testAnnotationWrapper, String arg1) { 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCode/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.cute.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButNonStaticMethod/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(TestAnnotation.class) 9 | public String shouldntWork(TestAnnotationWrapper testAnnotationWrapper, String arg1) { 10 | return "yes " + arg1; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButNonStaticMethod/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.cute.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButNotVisibleMethod/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(TestAnnotation.class) 9 | private static String shouldntWork(TestAnnotationWrapper testAnnotationWrapper, String arg1) { 10 | return "yes " + arg1; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButNotVisibleMethod/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.cute.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButWrongFirstParameter/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(TestAnnotation.class) 9 | public static String shouldntWork(String arg1) { 10 | return "yes " + arg1; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeButWrongFirstParameter/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.cute.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeReferencingGeneratedType/CustomCodeClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; 4 | import io.toolisticon.aptk.wrapper.test.TestAnnotation; 5 | 6 | public class CustomCodeClass { 7 | 8 | @CustomCodeMethod(TestAnnotation.class) 9 | public static TestAnnotation2Wrapper shouldWork(TestAnnotationWrapper testAnnotationWrapper) { 10 | return null; 11 | } 12 | 13 | @CustomCodeMethod(TestAnnotation.class) 14 | public static io.toolisticon.aptk.wrapper.othertest.TestAnnotation3Wrapper shouldWorkAsWell(TestAnnotationWrapper testAnnotationWrapper) { 15 | return null; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeReferencingGeneratedType/TestAnnotation2.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.test; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target(ElementType.TYPE) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface TestAnnotation2 { 13 | 14 | String value(); 15 | 16 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeReferencingGeneratedType/otherTest/TestAnnotation3.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.wrapper.othertest; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target(ElementType.TYPE) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface TestAnnotation3 { 13 | 14 | String value(); 15 | 16 | } -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeReferencingGeneratedType/otherTest/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = { TestAnnotation3.class}, automaticallyWrapEmbeddedAnnotations = false, usePublicVisibility = true) 2 | package io.toolisticon.aptk.wrapper.othertest; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.cute.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomCodeReferencingGeneratedType/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class, TestAnnotation2.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.aptk.wrapper.test.TestAnnotation; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withCustomInterface/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class}, customInterfaces = {@CustomInterface(annotationToWrap = TestAnnotation.class, interfacesToApply = {Serializable.class, Cloneable.class})}) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | import io.toolisticon.aptk.annotationwrapper.api.CustomInterface; 6 | import io.toolisticon.cute.TestAnnotation; 7 | 8 | import java.io.Serializable; 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withWrappingOfEmbedded/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class},automaticallyWrapEmbeddedAnnotations = true) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /annotationwrapper/processor/src/test/resources/testcase/withoutWrappingOfEmbedded/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper(value = {TestAnnotation.class},automaticallyWrapEmbeddedAnnotations = false) 2 | package io.toolisticon.aptk.wrapper.test; 3 | 4 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /aptk-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | io.toolisticon.aptk 5 | aptk-parent 6 | 0.30.3-SNAPSHOT 7 | 8 | aptk-api 9 | aptk-api 10 | 11 | 12 | 13 | 14 | maven-compiler-plugin 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /aptk-api/src/main/java/io/toolisticon/aptk/api/AnnotationToClassMapper.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.api; 2 | 3 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.Target; 9 | 10 | 11 | /** 12 | * This annotation supports mapping of annotation attributes to constructor or static method invocations. 13 | * It also allows mapping of annotated method parameters if annotated annotation type can be placed on method parameters. 14 | * 15 | */ 16 | 17 | @Documented 18 | @Retention(RUNTIME) 19 | @Target(ANNOTATION_TYPE) 20 | public @interface AnnotationToClassMapper { 21 | 22 | Class mappedClass(); 23 | 24 | /** 25 | * the attribute names to map against method or constructor parameters. 26 | * In case if an annotated annotation can be placed on Method Parameters, an empty String will trigger the usage of the corresponding parameter name. 27 | * Names enclosed in {} will be handled as wildcards (local variable references) which cannot be validated at compile time. So be careful if you use them. 28 | * @return 29 | */ 30 | String[] mappedAttributeNames(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /compilermessages/api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | aptk-compilermessages-api 6 | jar 7 | 8 | 9 | io.toolisticon.aptk 10 | aptk-compilermessages-parent 11 | 0.30.3-SNAPSHOT 12 | 13 | 14 | aptk-compilermessages-api 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /compilermessages/api/src/main/java/io/toolisticon/aptk/compilermessage/api/DeclareCompilerMessage.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.api; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Repeatable; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * This annotation allows to define a compiler message directly at the processor code or a method. 12 | * The annotation will be used to generate an enum that represents the available compiler messages. 13 | */ 14 | @Target({ElementType.METHOD, ElementType.TYPE}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Repeatable(DeclareCompilerMessages.class) 17 | @Documented 18 | public @interface DeclareCompilerMessage { 19 | 20 | /*+ 21 | * The compiler messages code. Must be unique. 22 | * Defaults to empty String which will result in that the enumValueName is going to be used. 23 | * @return the code of the message 24 | */ 25 | String code() default ""; 26 | 27 | 28 | /** 29 | * The name of the enum value. 30 | * Must be a valid enum name and must be unique within a compiler message enum. 31 | * @return the enum value name 32 | */ 33 | String enumValueName(); 34 | 35 | /** 36 | * The compiler message. Might contain zero based placeholders "${INDEX}". 37 | * @return the message 38 | */ 39 | String message(); 40 | 41 | /** 42 | * Binds the compiler message to a class. 43 | * If not set the compiler message will be generated in a file 44 | * @return 45 | */ 46 | Class processorClass() default Void.class; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /compilermessages/api/src/main/java/io/toolisticon/aptk/compilermessage/api/DeclareCompilerMessageCodePrefix.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.api; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Used to define a message code prefix. 11 | */ 12 | @Target({ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface DeclareCompilerMessageCodePrefix { 16 | 17 | /** 18 | * The prefix to be used in compiler message codes. 19 | * Defaults to class name if not explicitly set. 20 | * @return the message code prefix 21 | */ 22 | String value() default ""; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /compilermessages/api/src/main/java/io/toolisticon/aptk/compilermessage/api/DeclareCompilerMessages.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.api; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Target({ElementType.METHOD, ElementType.TYPE}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface DeclareCompilerMessages { 13 | DeclareCompilerMessage[] value(); 14 | } 15 | -------------------------------------------------------------------------------- /compilermessages/integrationtest/src/main/java/io/toolisticon/aptk/compilermessage/test/ByAnnotationAttribute.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.test; 2 | 3 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 4 | 5 | public class ByAnnotationAttribute { 6 | 7 | @DeclareCompilerMessage(processorClass = OnClassAndNestedClass.class, enumValueName = "BY_ANNOTATION", code="001", message = "Test ${0}") 8 | public static void doSomething() { 9 | System.out.println(OnClassAndNestedClassCompilerMessages.BY_ANNOTATION.getCode()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /compilermessages/integrationtest/src/main/java/io/toolisticon/aptk/compilermessage/test/OnClassAndNestedClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.test; 2 | 3 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 4 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessageCodePrefix; 5 | 6 | @DeclareCompilerMessageCodePrefix("WTF") 7 | @DeclareCompilerMessage(enumValueName = "ON_CLASS", code = "002",message = "ON CLASS Test ${0}") 8 | public class OnClassAndNestedClass { 9 | 10 | @DeclareCompilerMessage(enumValueName = "ON_CLASS_METHOD", code = "003",message = "ON CLASS METHOD Test ${0}") 11 | public void anotherMethod() { 12 | 13 | } 14 | 15 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS", code = "004",message = "ON NESTED CLASS Test ${0}") 16 | @DeclareCompilerMessage(enumValueName = "FOR_EMPTY_CODE_TEST1", message = "FOR_EMPTY_CODE_TEST") 17 | @DeclareCompilerMessage(enumValueName = "FOR_EMPTY_CODE_TEST2", message = "FOR_EMPTY_CODE_TEST") 18 | static class nestedClass { 19 | 20 | 21 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS_METHOD", code = "005",message = "ON NESTED CLASS METHOD Test ${0}") 22 | public void anotherNestedMethod() { 23 | 24 | } 25 | 26 | 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /compilermessages/processor/src/main/java/io/toolisticon/aptk/compilermessage/processor/package-info.java: -------------------------------------------------------------------------------- 1 | @AnnotationWrapper( 2 | value = {DeclareCompilerMessage.class, DeclareCompilerMessageCodePrefix.class}, 3 | bindCustomCode = {CompilerMessageWrapperCustomCode.class}, 4 | automaticallyWrapEmbeddedAnnotations = true, 5 | usePublicVisibility = true) 6 | package io.toolisticon.aptk.compilermessage.processor; 7 | 8 | import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; 9 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 10 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessageCodePrefix; 11 | -------------------------------------------------------------------------------- /compilermessages/processor/src/test/resources/testcase/error_nonUniqueCode/TestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.processor.test; 2 | 3 | 4 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 5 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessageCodePrefix; 6 | 7 | @DeclareCompilerMessageCodePrefix("WTF") 8 | public class TestClass { 9 | 10 | 11 | @DeclareCompilerMessage(enumValueName = "FIRST", code = "002", message = "TEST 1") 12 | @DeclareCompilerMessage(enumValueName = "SECOND", code = "002", message = "TEST 2") 13 | private void method1() { 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /compilermessages/processor/src/test/resources/testcase/error_nonUniqueEnumValueName/TestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.processor.test; 2 | 3 | 4 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 5 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessageCodePrefix; 6 | 7 | @DeclareCompilerMessageCodePrefix("WTF") 8 | @DeclareCompilerMessage(enumValueName = "ON_CLASS", code = "001", message = "TEST 1") 9 | public class TestClass { 10 | 11 | 12 | 13 | @DeclareCompilerMessage(enumValueName = "ON_METHOD", code = "002", message = "TEST 2") 14 | private void aMethod() { 15 | 16 | } 17 | 18 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS", code = "003", message = "TEST 3") 19 | static class NestedClass { 20 | 21 | 22 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS_METHOD", code = "004", message = "TEST 4") 23 | private void anotherMethod() { 24 | 25 | } 26 | 27 | } 28 | 29 | 30 | } -------------------------------------------------------------------------------- /compilermessages/processor/src/test/resources/testcase/happyPath_OnClass/RemoteTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.processor.test; 2 | 3 | 4 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 5 | 6 | @DeclareCompilerMessage(processorClass = io.toolisticon.aptk.compilermessage.processor.test.TestClass.class, enumValueName = "ON_REMOTE_CLASS", code = "005", message = "TEST 5") 7 | public class RemoteTestClass { 8 | 9 | } -------------------------------------------------------------------------------- /compilermessages/processor/src/test/resources/testcase/happyPath_OnClass/TestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.compilermessage.processor.test; 2 | 3 | 4 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessage; 5 | import io.toolisticon.aptk.compilermessage.api.DeclareCompilerMessageCodePrefix; 6 | 7 | @DeclareCompilerMessageCodePrefix("WTF") 8 | @DeclareCompilerMessage(enumValueName = "ON_CLASS", code = "001", message = "TEST 1") 9 | @DeclareCompilerMessage(enumValueName = "ON_CLASS_WO_CODE", message = "TEST 6") 10 | public class TestClass { 11 | 12 | 13 | 14 | @DeclareCompilerMessage(enumValueName = "ON_METHOD", code = "002", message = "TEST 2") 15 | private void aMethod() { 16 | 17 | } 18 | 19 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS", code = "003", message = "TEST 3") 20 | static class NestedClass { 21 | 22 | 23 | @DeclareCompilerMessage(enumValueName = "ON_NESTED_CLASS_METHOD", code = "004", message = "TEST 4") 24 | private void anotherMethod() { 25 | 26 | } 27 | 28 | } 29 | 30 | 31 | } -------------------------------------------------------------------------------- /config/findbugs-excludes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessor.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.cute; 2 | 3 | import io.toolisticon.aptk.common.ToolingProvider; 4 | import io.toolisticon.cute.UnitTest; 5 | 6 | import javax.annotation.processing.ProcessingEnvironment; 7 | import javax.lang.model.element.Element; 8 | 9 | /** 10 | * Convenient unit test processor for unit testing code based on APTK with toolisticon's cute framework. 11 | */ 12 | public abstract class APTKUnitTestProcessor implements UnitTest { 13 | 14 | /** 15 | * The original unit test processor method. Contains logic to initialize the ToolingProvider. 16 | * Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. 17 | * 18 | * @param processingEnvironment the processing environment 19 | * @param element the passed in element 20 | */ 21 | @Override 22 | public final void unitTest(ProcessingEnvironment processingEnvironment, ELEMENT_TYPE element) { 23 | 24 | try { 25 | // do initializations 26 | ToolingProvider.setTooling(processingEnvironment); 27 | 28 | // propagate to unit test implementation 29 | this.aptkUnitTest(processingEnvironment, element); 30 | 31 | } finally { 32 | ToolingProvider.clearTooling(); 33 | } 34 | 35 | } 36 | 37 | /** 38 | * The unit test method. 39 | * 40 | * @param processingEnvironment the processingEnvironment 41 | * @param typeElement the element the underlying annotation processor is applied on 42 | */ 43 | public abstract void aptkUnitTest(ProcessingEnvironment processingEnvironment, ELEMENT_TYPE typeElement); 44 | } 45 | -------------------------------------------------------------------------------- /cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorWithoutPassIn.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.cute; 2 | 3 | import io.toolisticon.aptk.common.ToolingProvider; 4 | import io.toolisticon.cute.UnitTestWithoutPassIn; 5 | 6 | import javax.annotation.processing.ProcessingEnvironment; 7 | 8 | public abstract class APTKUnitTestProcessorWithoutPassIn implements UnitTestWithoutPassIn { 9 | 10 | /** 11 | * The original unit test processor method. Contains logic to initialize the ToolingProvider. 12 | * Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. 13 | * 14 | * @param processingEnvironment the processing environment 15 | */ 16 | @Override 17 | public final void unitTest(ProcessingEnvironment processingEnvironment) { 18 | 19 | try { 20 | // do initializations 21 | ToolingProvider.setTooling(processingEnvironment); 22 | 23 | // propagate to unit test implementation 24 | this.aptkUnitTest(processingEnvironment); 25 | 26 | } finally { 27 | ToolingProvider.clearTooling(); 28 | } 29 | 30 | } 31 | 32 | /** 33 | * The unit test method. 34 | * 35 | * @param processingEnvironment the processingEnvironment 36 | */ 37 | public abstract void aptkUnitTest(ProcessingEnvironment processingEnvironment); 38 | } -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Annotation-Processor-Toolkit Example 2 | 3 | This example demonstrates how annotation processors can be build using the annotation-processor-toolkit and how they can be used. 4 | 5 | The example consists of 3 parts: 6 | 7 | - module that contains the annotations : [example-annotations/](example-annotations/) 8 | - module of the annotation processor : [example-annotationprocessor](example-annotationprocessor/) 9 | - An usecase that demonstrates the usage of the annotation processor : [example-usecase](example-usecase/) 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/implementsSpecificInterfaceCheckAnnotationProcessor/InvalidUsageTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.ImplementsSpecificInterfaceCheckAnnotation; 4 | 5 | @ImplementsSpecificInterfaceCheckAnnotation 6 | public class InvalidUsageTest { 7 | 8 | 9 | } -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.ImplementsSpecificInterfaceCheckAnnotation; 4 | import io.toolisticon.aptk.example.annotations.SpecificInterface; 5 | 6 | @ImplementsSpecificInterfaceCheckAnnotation 7 | public class ValidUsageTest implements SpecificInterface{ 8 | 9 | 10 | public String testMethod() { 11 | return null; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTestExtendsCase.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.ImplementsSpecificInterfaceCheckAnnotation; 4 | import io.toolisticon.aptk.example.annotations.SpecificInterface; 5 | 6 | 7 | public class ValidUsageTestExtendsCase { 8 | 9 | public static class SuperClass implements SpecificInterface { 10 | 11 | public String testMethod() { 12 | return null; 13 | } 14 | 15 | } 16 | 17 | 18 | @ImplementsSpecificInterfaceCheckAnnotation 19 | public static class SubClass extends SuperClass { 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/methodWithOneStringParameterAndVoidReturn/InvalidUsageNonStringParameter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; 4 | 5 | public class InvalidUsageNonStringParameter { 6 | 7 | @MethodWithOneStringParameterAndVoidReturnTypeAnnotation 8 | public void test(Object x) { 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/methodWithOneStringParameterAndVoidReturn/InvalidUsageNonVoidReturnType.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; 4 | 5 | public class InvalidUsageNonVoidReturnType { 6 | 7 | @MethodWithOneStringParameterAndVoidReturnTypeAnnotation 8 | public String test(String x) { 9 | return "XXX"; 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /example/example-annotationprocessor/src/test/resources/testcases/methodWithOneStringParameterAndVoidReturn/ValidUsageTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.example.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; 4 | 5 | public class ValidUsageTest { 6 | 7 | @MethodWithOneStringParameterAndVoidReturnTypeAnnotation 8 | public void test(String x) { 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /example/example-annotations/README.md: -------------------------------------------------------------------------------- 1 | # Annotation-Processor-Toolkit Example Annotations 2 | 3 | This module contains some example annotation which are processed by the [example annotation processor](../example-annotationprocessor). 4 | 5 | ## Annotations 6 | ### MethodWithOneStringParameterAndVoidReturnTypeAnnotation 7 | This annotation must be used on methods which must have exactly one parameter of type String and a void return type. 8 | 9 | ### TypeThatIsAssignableToInterfaceAnnotation 10 | This annotation must be used on type which must implement the _SomeInterface_ interface 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/example-annotations/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | aptk-example-annotations 5 | jar 6 | 7 | 8 | io.toolisticon.aptk 9 | aptk-example-parent 10 | 0.30.3-SNAPSHOT 11 | 12 | 13 | aptk-example-annotations 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /example/example-annotations/src/main/java/io/toolisticon/aptk/example/annotations/ImplementsSpecificInterfaceCheckAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Test annotation for annotating classes that must implement a the {@link SpecificInterface} interface. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | public @interface ImplementsSpecificInterfaceCheckAnnotation { 14 | } 15 | -------------------------------------------------------------------------------- /example/example-annotations/src/main/java/io/toolisticon/aptk/example/annotations/MethodWithOneStringParameterAndVoidReturnTypeAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Test annotation for annotating methods that must have exactly one Parameter of type String and a void return type. 10 | */ 11 | @Retention(value = RetentionPolicy.RUNTIME) 12 | @Target(value = ElementType.METHOD) 13 | public @interface MethodWithOneStringParameterAndVoidReturnTypeAnnotation { 14 | } 15 | -------------------------------------------------------------------------------- /example/example-annotations/src/main/java/io/toolisticon/aptk/example/annotations/SpecificInterface.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.annotations; 2 | 3 | 4 | public interface SpecificInterface { 5 | String testMethod(); 6 | } 7 | -------------------------------------------------------------------------------- /example/example-usecase/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated_tests/ 2 | -------------------------------------------------------------------------------- /example/example-usecase/README.md: -------------------------------------------------------------------------------- 1 | # Annotation-Processor-Toolkit Example Usecase 2 | 3 | This example usecase demonstrates how the annotation processor can be used. 4 | 5 | Feel free to play around a bit and to change the example usecase into invalid usage of the annotations. 6 | Afterwards build everything with: 7 | 8 | mvn clean install 9 | 10 | In this case of broken constraints compiling of the example should result into a compile error. 11 | 12 | This will be shown both on console and even in your IDE. 13 | 14 | -------------------------------------------------------------------------------- /example/example-usecase/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | aptk-example-usecase 5 | jar 6 | 7 | 8 | io.toolisticon.aptk 9 | aptk-example-parent 10 | 0.30.3-SNAPSHOT 11 | 12 | 13 | aptk-example-usecase 14 | 15 | 16 | 17 | 18 | 19 | io.toolisticon.aptk 20 | aptk-example-annotations 21 | 22 | 23 | 24 | io.toolisticon.aptk 25 | aptk-example-annotationprocessor 26 | provided 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/example-usecase/src/main/java/io/toolisticon/aptk/example/usecase/TestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.usecase; 2 | 3 | import io.toolisticon.aptk.example.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; 4 | import io.toolisticon.aptk.example.annotations.SpecificInterface; 5 | import io.toolisticon.aptk.example.annotations.ImplementsSpecificInterfaceCheckAnnotation; 6 | 7 | /** 8 | * Test class to show that the annotation processors are working correctly. 9 | */ 10 | 11 | 12 | @ImplementsSpecificInterfaceCheckAnnotation 13 | public class TestClass implements SpecificInterface { 14 | 15 | @MethodWithOneStringParameterAndVoidReturnTypeAnnotation 16 | public void testMethod(String a) { 17 | 18 | } 19 | 20 | @Override 21 | public String testMethod() { 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /idea_aptk_codestyle.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /integrationtest/java16/src/main/java/io/toolisticon/aptk/integrationtest/java16/DummyClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java16; 2 | 3 | /** 4 | * Dummy Class for fixing build. 5 | */ 6 | public class DummyClass { 7 | } 8 | -------------------------------------------------------------------------------- /integrationtest/java16/src/main/java/io/toolisticon/aptk/integrationtest/java16/package-info.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java16; -------------------------------------------------------------------------------- /integrationtest/java17/src/main/java/io/toolisticon/aptk/integrationtest/java17/DummyClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java17; 2 | 3 | /** 4 | * Dummy Class for fixing build. 5 | */ 6 | public class DummyClass { 7 | } 8 | -------------------------------------------------------------------------------- /integrationtest/java17/src/main/java/io/toolisticon/aptk/integrationtest/java17/package-info.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java17; -------------------------------------------------------------------------------- /integrationtest/java9/src/main/java/io/toolisticon/aptk/integrationtest/java9/DummyClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java9; 2 | 3 | /** 4 | * Dummy Class for fixing build. 5 | */ 6 | public class DummyClass { 7 | } 8 | -------------------------------------------------------------------------------- /integrationtest/java9/src/main/java/io/toolisticon/aptk/integrationtest/java9/package-info.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.integrationtest.java9; -------------------------------------------------------------------------------- /integrationtest/java9/src/test/resources/testcases/namedModule/MyProcessor.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.regularmodule; 2 | 3 | import javax.annotation.processing.AbstractProcessor; 4 | import javax.annotation.processing.RoundEnvironment; 5 | import javax.lang.model.element.TypeElement; 6 | import java.util.Set; 7 | 8 | public class MyProcessor extends AbstractProcessor { 9 | 10 | 11 | @Override 12 | public boolean process(Set annotations, RoundEnvironment roundEnv) { 13 | return false; 14 | } 15 | } -------------------------------------------------------------------------------- /integrationtest/java9/src/test/resources/testcases/namedModule/TestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.example.regularmodule; 2 | 3 | import io.toolisticon.cute.PassIn; 4 | 5 | @PassIn 6 | public class TestClass{ 7 | 8 | } -------------------------------------------------------------------------------- /integrationtest/java9/src/test/resources/testcases/namedModule/module-info.java: -------------------------------------------------------------------------------- 1 | import javax.annotation.processing.Processor; 2 | 3 | module io.toolisticon.aptk.example { 4 | 5 | exports io.toolisticon.aptk.example.regularmodule to cute; 6 | requires transitive cute; 7 | requires static jdk.compiler; 8 | uses Processor; 9 | opens io.toolisticon.aptk.example.regularmodule to cute; 10 | provides Processor with io.toolisticon.aptk.example.regularmodule.MyProcessor; 11 | 12 | } -------------------------------------------------------------------------------- /templating/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | aptk-templating 5 | jar 6 | 7 | 8 | io.toolisticon.aptk 9 | aptk-parent 10 | 0.30.3-SNAPSHOT 11 | 12 | 13 | aptk-templating 14 | 15 | 16 | 17 | 18 | 19 | 20 | maven-compiler-plugin 21 | 22 | true 23 | ${java.compile.source.version} 24 | ${java.compile.target.version} 25 | none 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/NextDetectedBlockResult.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating; 2 | 3 | import io.toolisticon.aptk.templating.templateblocks.TemplateBlockType; 4 | 5 | /** 6 | * Used by {@link TemplateBlockType} to return next detected block. 7 | */ 8 | public class NextDetectedBlockResult { 9 | 10 | private final TemplateBlockType templateBlockType; 11 | private final int beginIndex; 12 | private final int endIndex; 13 | private final String attributes; 14 | private final String content; 15 | private final String remainingStringToBeProcessed; 16 | 17 | public NextDetectedBlockResult( 18 | TemplateBlockType templateBlockType, 19 | int beginIndex, 20 | int endIndex, 21 | String attributes, 22 | String content, 23 | String remainingStringToBeProcessed) { 24 | this.templateBlockType = templateBlockType; 25 | this.beginIndex = beginIndex; 26 | this.endIndex = endIndex; 27 | this.attributes = attributes; 28 | this.content = content; 29 | this.remainingStringToBeProcessed = remainingStringToBeProcessed; 30 | } 31 | 32 | public TemplateBlockType getTemplateBlockType() { 33 | return templateBlockType; 34 | } 35 | 36 | public int getBeginIndex() { 37 | return beginIndex; 38 | } 39 | 40 | public int getEndIndex() { 41 | return endIndex; 42 | } 43 | 44 | public String getAttributes() { 45 | return attributes; 46 | } 47 | 48 | public String getContent() { 49 | return content; 50 | } 51 | 52 | public String getRemainingStringToBeProcessed() { 53 | return this.remainingStringToBeProcessed; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/TemplateProcessor.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating; 2 | 3 | import io.toolisticon.aptk.templating.templateblocks.TemplateBlockBinder; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Base class for parsing templates. 9 | */ 10 | public class TemplateProcessor { 11 | 12 | 13 | public static String processTemplate(String templateString, Map values) { 14 | 15 | TemplateBlockBinder binder = ParseUtilities.parseString(templateString); 16 | return binder.getContent(values); 17 | 18 | } 19 | 20 | public static String processTemplateResourceFile(String templateFileName, Map values) { 21 | 22 | String templateString = null; 23 | try { 24 | templateString = ParseUtilities.readResourceToString(templateFileName); 25 | } catch (Exception e) { 26 | throw new IllegalArgumentException("Cannot open template file '" + templateFileName + "'", e); 27 | } 28 | 29 | return processTemplate(templateString, values); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/exceptions/InvalidElseIfException.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.exceptions; 2 | 3 | /** 4 | * Exception that is thrown if an if control block has multiple else cases. 5 | */ 6 | public class InvalidElseIfException extends RuntimeException { 7 | 8 | public InvalidElseIfException(String message) { 9 | super(message); 10 | } 11 | 12 | public InvalidElseIfException(String message, Throwable e) { 13 | super(message, e); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/exceptions/InvalidExpressionResult.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.exceptions; 2 | 3 | /** 4 | * Exception is thrown if the result of an expression has an unexpected type. 5 | */ 6 | public class InvalidExpressionResult extends RuntimeException { 7 | 8 | public InvalidExpressionResult(String message) { 9 | super(message); 10 | } 11 | 12 | public InvalidExpressionResult(String message, Throwable e) { 13 | super(message,e); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/exceptions/InvalidIncludeModelExpression.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.exceptions; 2 | 3 | /** 4 | * Exception is thrown if a statement to setup the model in include command is incorrect. 5 | */ 6 | public class InvalidIncludeModelExpression extends RuntimeException{ 7 | 8 | public InvalidIncludeModelExpression(String message) { 9 | super(message); 10 | } 11 | 12 | public InvalidIncludeModelExpression(String message, Throwable e) { 13 | super(message,e); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/exceptions/InvalidPathException.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.exceptions; 2 | 3 | /** 4 | * Exception that is thrown if a path seems to be invalid. 5 | *

6 | * This may occur if a path token is applied on a primitive or array. 7 | */ 8 | public class InvalidPathException extends RuntimeException { 9 | 10 | public InvalidPathException(String message) { 11 | super(message); 12 | } 13 | 14 | public InvalidPathException(String message, Throwable e) { 15 | super(message, e); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/exceptions/MissingClosingTagException.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.exceptions; 2 | 3 | /** 4 | * Exception that is thrown if a control block seems not to be properly ended. 5 | */ 6 | public class MissingClosingTagException extends RuntimeException { 7 | 8 | public MissingClosingTagException(String message) { 9 | super(message); 10 | } 11 | 12 | public MissingClosingTagException(String message, Throwable e) { 13 | super(message, e); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/AbstractSearchResult.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions; 2 | 3 | /** 4 | * Abstract search result for parsing of expressions. 5 | */ 6 | public abstract class AbstractSearchResult { 7 | 8 | 9 | private final int startIndex; 10 | private final int endIndex; 11 | private final T value; 12 | 13 | public AbstractSearchResult(T value, int startIndex, int endIndex ) { 14 | this.startIndex = startIndex; 15 | this.endIndex = endIndex; 16 | this.value = value; 17 | } 18 | 19 | public int getStartIndex() { 20 | return startIndex; 21 | } 22 | 23 | public int getEndIndex() { 24 | return endIndex; 25 | } 26 | 27 | public T getValue() { 28 | return value; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/BooleanOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | /** 4 | * Boolean based operand. 5 | * Uses Boolean.valueOf to determine value of passed expression string. 6 | */ 7 | public class BooleanOperand extends ParsedOperand { 8 | 9 | public BooleanOperand(String expressionString) { 10 | super(expressionString); 11 | } 12 | 13 | 14 | @Override 15 | public Class getOperandsJavaType() { 16 | return Boolean.class; 17 | } 18 | 19 | @Override 20 | public Boolean value() { 21 | return Boolean.valueOf(getExpressionString()); 22 | } 23 | 24 | @Override 25 | public OperandType getOperandType() { 26 | return OperandType.BOOLEAN; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/DoubleOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | 4 | /** 5 | * Floating point based operand. 6 | * 7 | * Uses Double.valueOf to get value from expression. 8 | */ 9 | public class DoubleOperand extends ParsedOperand { 10 | 11 | public DoubleOperand( String expressionString) { 12 | super( expressionString); 13 | 14 | } 15 | 16 | @Override 17 | public Class getOperandsJavaType() { 18 | return Double.class; 19 | } 20 | 21 | @Override 22 | public Double value() { 23 | return Double.valueOf(getExpressionString()); 24 | } 25 | 26 | @Override 27 | public OperandType getOperandType() { 28 | return OperandType.DOUBLE; 29 | } 30 | } -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/DynamicOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import io.toolisticon.aptk.templating.ModelPathResolver; 4 | 5 | 6 | /** 7 | * Dynamic operand queried from models. 8 | */ 9 | public class DynamicOperand extends ParsedOperand { 10 | 11 | private Object value; 12 | 13 | public DynamicOperand(String expressionString) { 14 | super(expressionString); 15 | 16 | } 17 | 18 | @Override 19 | public Class getOperandsJavaType() { 20 | 21 | ModelPathResolver.ResolvedModelPathResult result = ModelPathResolver.resolveModelPath(ModelPathResolver.modelMapThreadLocal.get(), getExpressionString()); 22 | 23 | // result cannot be null 24 | return result.getType(); 25 | 26 | } 27 | 28 | @Override 29 | public Object value() { 30 | 31 | ModelPathResolver.ResolvedModelPathResult result = ModelPathResolver.resolveModelPath(ModelPathResolver.modelMapThreadLocal.get(), getExpressionString()); 32 | 33 | // result cannot be null 34 | return result.getValue(); 35 | 36 | } 37 | 38 | @Override 39 | public OperandType getOperandType() { 40 | return OperandType.DYNAMIC_VALUE; 41 | } 42 | } -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/ExpressionOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import io.toolisticon.aptk.templating.expressions.Expression; 4 | 5 | /** 6 | * Expression Based Operand. 7 | */ 8 | public class ExpressionOperand extends ParsedOperand { 9 | 10 | private final Expression expression; 11 | 12 | private Operand calculatedExpressionOperand; 13 | 14 | public ExpressionOperand( String expressionString, Expression expression) { 15 | super( expressionString); 16 | 17 | this.expression = expression; 18 | } 19 | 20 | public Expression getExpression() { 21 | return expression; 22 | } 23 | 24 | @Override 25 | public Class getOperandsJavaType() { 26 | return calculateExpression().getOperandsJavaType(); 27 | } 28 | 29 | @Override 30 | public Object value() { 31 | return calculateExpression().value(); 32 | } 33 | 34 | @Override 35 | public OperandType getOperandType() { 36 | return OperandType.EXPRESSION; 37 | } 38 | 39 | private Operand calculateExpression() { 40 | if (this.calculatedExpressionOperand == null) { 41 | this.calculatedExpressionOperand = expression.evaluateExpression(); 42 | } 43 | return calculatedExpressionOperand; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/LongOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | /** 4 | * String based operand. 5 | */ 6 | public class LongOperand extends ParsedOperand { 7 | 8 | public LongOperand(String expressionString) { 9 | super(expressionString); 10 | 11 | } 12 | 13 | @Override 14 | public Class getOperandsJavaType() { 15 | return Long.class; 16 | } 17 | 18 | @Override 19 | public Long value() { 20 | return Long.valueOf(getExpressionString()); 21 | } 22 | 23 | @Override 24 | public OperandType getOperandType() { 25 | return OperandType.LONG; 26 | } 27 | } -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/NullValueOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | /** 4 | * Operand that represents a null value. 5 | * Internal Java Type is null. 6 | */ 7 | public class NullValueOperand extends ParsedOperand { 8 | 9 | public NullValueOperand(String expressionString) { 10 | super(expressionString); 11 | 12 | } 13 | 14 | 15 | @Override 16 | public Class getOperandsJavaType() { 17 | return null; 18 | } 19 | 20 | @Override 21 | public Object value() { 22 | return null; 23 | } 24 | 25 | @Override 26 | public OperandType getOperandType() { 27 | return OperandType.NULL_VALUE; 28 | } 29 | 30 | 31 | } -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/OperandTypeSearchResult.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | 4 | import io.toolisticon.aptk.templating.expressions.AbstractSearchResult; 5 | 6 | public class OperandTypeSearchResult extends AbstractSearchResult { 7 | public OperandTypeSearchResult(OperandType value, int startIndex, int endIndex) { 8 | super(value, startIndex, endIndex); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/OperationResultOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | /** 4 | * Used to hold an Operation result 5 | */ 6 | public class OperationResultOperand extends Operand { 7 | 8 | private final Class type; 9 | private final Object value; 10 | 11 | public OperationResultOperand(Class type, Object value) { 12 | super(); 13 | 14 | this.type = type; 15 | this.value = value; 16 | 17 | } 18 | 19 | @Override 20 | public Class getOperandsJavaType() { 21 | return type; 22 | } 23 | 24 | @Override 25 | public Object value() { 26 | return value; 27 | } 28 | 29 | @Override 30 | public OperandType getOperandType() { 31 | return OperandType.OPERATION_RESULT; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/ParsedOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | /** 4 | * Abstract base class for operands parsed from expression. 5 | */ 6 | public abstract class ParsedOperand extends Operand { 7 | 8 | private final String expressionString; 9 | 10 | 11 | public ParsedOperand(String expressionString) { 12 | super(); 13 | 14 | if (expressionString == null) { 15 | throw new IllegalArgumentException("expression String for ParsedOperand must not be null"); 16 | } 17 | 18 | this.expressionString = expressionString.trim(); 19 | 20 | } 21 | 22 | public String getExpressionString() { 23 | return expressionString; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operands/StringOperand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import java.util.regex.Matcher; 4 | 5 | /** 6 | * String based operand. 7 | */ 8 | public class StringOperand extends ParsedOperand { 9 | 10 | private final String internalValue; 11 | 12 | public StringOperand(String expressionString) { 13 | super(expressionString); 14 | 15 | 16 | Matcher matcher = getOperandType().getOperandPattern().matcher(expressionString); 17 | if (matcher.find()) { 18 | 19 | String tempValue = matcher.group(1); 20 | 21 | // replace escaped single quotes 22 | tempValue = tempValue.replaceAll("\\\\[']", "'"); 23 | 24 | // replace escaped escape chars 25 | tempValue = tempValue.replaceAll("\\\\", "\\"); 26 | 27 | 28 | internalValue = tempValue; 29 | 30 | } else { 31 | internalValue = null; 32 | } 33 | 34 | 35 | } 36 | 37 | @Override 38 | public Class getOperandsJavaType() { 39 | return String.class; 40 | } 41 | 42 | @Override 43 | public String value() { 44 | return internalValue; 45 | } 46 | 47 | @Override 48 | public OperandType getOperandType() { 49 | return OperandType.STRING; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operations/OperationTypeMode.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operations; 2 | 3 | 4 | /** 5 | * Defines the operation type mode. 6 | * Helps to determine the number of operands 7 | */ 8 | public enum OperationTypeMode { 9 | UNARY(1), 10 | BINARY(2); 11 | 12 | private final int numberOfOperands; 13 | 14 | OperationTypeMode(int numberOfOperands) { 15 | this.numberOfOperands = numberOfOperands; 16 | } 17 | 18 | public int getNumberOfOperands() { 19 | return numberOfOperands; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/expressions/operations/OperationTypeSearchResult.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operations; 2 | 3 | 4 | import io.toolisticon.aptk.templating.expressions.AbstractSearchResult; 5 | 6 | public class OperationTypeSearchResult extends AbstractSearchResult { 7 | public OperationTypeSearchResult(OperationType value, int startIndex, int endIndex) { 8 | super(value, startIndex, endIndex); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/templateblocks/PlainTextTemplateBlock.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Block for a plain text template block. 7 | */ 8 | public class PlainTextTemplateBlock implements TemplateBlock { 9 | 10 | private final String content; 11 | 12 | public PlainTextTemplateBlock(String content) { 13 | this.content = content; 14 | } 15 | 16 | @Override 17 | public TemplateBlockType getTemplateBlockType() { 18 | return TemplateBlockType.PLAIN_TEXT; 19 | } 20 | 21 | public String getContent(Map variables) { 22 | return content; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/templateblocks/StaticTemplateBlock.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Used to define static template blocks. 7 | */ 8 | public class StaticTemplateBlock implements TemplateBlock { 9 | 10 | private final String content; 11 | 12 | public StaticTemplateBlock(String content) { 13 | this.content = content; 14 | } 15 | 16 | 17 | @Override 18 | public TemplateBlockType getTemplateBlockType() { 19 | return TemplateBlockType.STATIC; 20 | } 21 | 22 | @Override 23 | public String getContent(Map variables) { 24 | return content; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/templateblocks/TemplateBlock.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Interface to handle different kind of template blocks. 7 | */ 8 | 9 | public interface TemplateBlock { 10 | 11 | /** 12 | * Used to determine template block type. 13 | * 14 | * @return the type of the template block 15 | */ 16 | TemplateBlockType getTemplateBlockType(); 17 | 18 | /** 19 | * Gets string representation for this template block. 20 | * 21 | * @param variables the variables used for processing the content block 22 | * @return the string representation of this block. 23 | */ 24 | String getContent(Map variables); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/templateblocks/TemplateBlockBinder.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | /** 8 | * 9 | */ 10 | public class TemplateBlockBinder implements TemplateBlock { 11 | 12 | private final List templateBlocks = new ArrayList(); 13 | 14 | 15 | public TemplateBlockBinder( String templateString) { 16 | } 17 | 18 | @Override 19 | public TemplateBlockType getTemplateBlockType() { 20 | return TemplateBlockType.BINDER; 21 | } 22 | 23 | @Override 24 | public String getContent(Map variables) { 25 | 26 | StringBuilder stringBuilder = new StringBuilder(); 27 | 28 | for (TemplateBlock templateBlock : templateBlocks) { 29 | stringBuilder.append(templateBlock.getContent(variables)); 30 | } 31 | 32 | return stringBuilder.toString(); 33 | } 34 | 35 | public List getTemplateBlocks(){ 36 | return this.templateBlocks; 37 | } 38 | 39 | public void addTemplateBlock(TemplateBlock templateBlock) { 40 | templateBlocks.add(templateBlock); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /templating/src/main/java/io/toolisticon/aptk/templating/templateblocks/VariableTextTemplateBlock.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import io.toolisticon.aptk.templating.expressions.Expression; 4 | import io.toolisticon.aptk.templating.expressions.ExpressionParser; 5 | import io.toolisticon.aptk.templating.expressions.operands.Operand; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * 11 | */ 12 | public class VariableTextTemplateBlock implements TemplateBlock { 13 | 14 | 15 | private final String accessPath; 16 | 17 | public VariableTextTemplateBlock(String accessPath) { 18 | if (accessPath == null || accessPath.trim().isEmpty()) { 19 | throw new IllegalArgumentException("Passed accessPath must not be null or empty"); 20 | } 21 | this.accessPath = accessPath; 22 | } 23 | 24 | 25 | @Override 26 | public TemplateBlockType getTemplateBlockType() { 27 | return TemplateBlockType.DYNAMIC_TEXT; 28 | } 29 | 30 | @Override 31 | public String getContent(Map variables) { 32 | 33 | 34 | Expression expression = ExpressionParser.parseExpression(accessPath, variables); 35 | Operand result = expression.evaluateExpression(); 36 | 37 | return result.value() != null ? result.value().toString() : null; 38 | 39 | } 40 | 41 | protected String getAccessPath() { 42 | return this.accessPath; 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/TemplateProcessorTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * Unit test for {@link TemplateProcessor}. 12 | */ 13 | public class TemplateProcessorTest { 14 | 15 | @Test 16 | public void testTemplateString() { 17 | 18 | Map map = new HashMap(); 19 | map.put("test", "YEP"); 20 | 21 | MatcherAssert.assertThat(TemplateProcessor.processTemplate("${test}", map), Matchers.is("YEP")); 22 | 23 | 24 | } 25 | 26 | @Test 27 | public void testTemplateFile() { 28 | 29 | Map map = new HashMap(); 30 | map.put("test", "YEP"); 31 | 32 | MatcherAssert.assertThat(TemplateProcessor.processTemplateResourceFile("/TestTemplateProcessorTemplateFile.tpl", map), Matchers.is("YEP")); 33 | 34 | 35 | } 36 | 37 | @Test(expected = IllegalArgumentException.class) 38 | public void testTemplateFile_withNonExistingFile() { 39 | 40 | Map map = new HashMap(); 41 | map.put("test", "YEP"); 42 | 43 | TemplateProcessor.processTemplateResourceFile("/XXX.tpl", map); 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operands/BooleanOperandTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for {@link BooleanOperand}. 9 | */ 10 | public class BooleanOperandTest { 11 | 12 | @Test(expected = IllegalArgumentException.class) 13 | public void test_passedNullValue() { 14 | new BooleanOperand(null).value(); 15 | } 16 | 17 | 18 | @Test 19 | public void test_getOperandsJavaType() { 20 | 21 | MatcherAssert.assertThat(new BooleanOperand("true").getOperandsJavaType(), Matchers.equalTo((Class) Boolean.class)); 22 | 23 | } 24 | 25 | @Test 26 | public void test_createBooleanOperand() { 27 | 28 | MatcherAssert.assertThat((Boolean) new BooleanOperand("true").value(), Matchers.is(true)); 29 | MatcherAssert.assertThat((Boolean) new BooleanOperand("false").value(), Matchers.is(false)); 30 | 31 | } 32 | 33 | 34 | @Test 35 | public void test_nonBooleanValue() { 36 | MatcherAssert.assertThat((Boolean) new BooleanOperand("XYZ").value(), Matchers.is(false)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operands/DoubleOperandTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for {@link DoubleOperand}. 9 | */ 10 | public class DoubleOperandTest { 11 | 12 | @Test(expected = IllegalArgumentException.class) 13 | public void test_passedNullValue() { 14 | new DoubleOperand(null).value(); 15 | } 16 | 17 | 18 | 19 | @Test 20 | public void test_getOperandsJavaType() { 21 | 22 | MatcherAssert.assertThat(new DoubleOperand("6.0").getOperandsJavaType(), Matchers.equalTo((Class) Double.class)); 23 | 24 | } 25 | 26 | @Test 27 | public void test_createDoubleOperand() { 28 | 29 | MatcherAssert.assertThat((Double) new DoubleOperand("6.0").value(), Matchers.is(6.0)); 30 | MatcherAssert.assertThat((Double) new DoubleOperand("-6.0").value(), Matchers.is(-6.0)); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operands/LongOperandTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for {@link LongOperand}. 9 | */ 10 | public class LongOperandTest { 11 | 12 | @Test(expected = IllegalArgumentException.class) 13 | public void test_passedNullValue() { 14 | new LongOperand(null).value(); 15 | } 16 | 17 | 18 | @Test 19 | public void test_getOperandsJavaType() { 20 | 21 | MatcherAssert.assertThat(new LongOperand("6").getOperandsJavaType(), Matchers.equalTo((Class) Long.class)); 22 | 23 | } 24 | 25 | @Test 26 | public void test_createLongOperand() { 27 | 28 | MatcherAssert.assertThat((Long) new LongOperand("6").value(), Matchers.is(6L)); 29 | MatcherAssert.assertThat((Long) new LongOperand("-6").value(), Matchers.is(-6L)); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operands/NullValueOperandTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit test for {@link NullValueOperand}. 9 | */ 10 | public class NullValueOperandTest { 11 | 12 | @Test(expected = IllegalArgumentException.class) 13 | public void test_passedNullValue() { 14 | new BooleanOperand(null).value(); 15 | } 16 | 17 | 18 | @Test 19 | public void test_getOperandsJavaType() { 20 | 21 | MatcherAssert.assertThat(new NullValueOperand("null").getOperandsJavaType(), Matchers.nullValue()); 22 | 23 | } 24 | 25 | @Test 26 | public void test_getValue() { 27 | 28 | MatcherAssert.assertThat(new NullValueOperand("null").value(), Matchers.nullValue()); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operands/OperandFactoryTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operands; 2 | 3 | import io.toolisticon.aptk.templating.expressions.operations.OperationType; 4 | import org.junit.Test; 5 | 6 | /** 7 | * Unit test for {@link OperandFactory}. 8 | */ 9 | public class OperandFactoryTest { 10 | 11 | @Test(expected = IllegalArgumentException.class) 12 | public void createOperand_nullValued_operandType() { 13 | OperandFactory.createOperand(null, "ABC", new OperationType[0], null); 14 | } 15 | 16 | @Test(expected = IllegalArgumentException.class) 17 | public void createOperand_nullValued_expressionString() { 18 | OperandFactory.createOperand(OperandType.BOOLEAN, null, new OperationType[0], null); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/expressions/operations/OperationTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.expressions.operations; 2 | 3 | 4 | public class OperationTest { 5 | 6 | /*- 7 | @Test(expected = IllegalArgumentException.class) 8 | public void getOperation_testNullValue() { 9 | Operation.OperationType.getOperationType(null); 10 | } 11 | 12 | @Test 13 | public void getOperation_testEqualOperations() { 14 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc==sas"), Matchers.is(Operation.OperationType.EQUAL)); 15 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc == sas"), Matchers.is(Operation.OperationType.EQUAL)); 16 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc == sas"), Matchers.is(Operation.OperationType.EQUAL)); 17 | } 18 | 19 | @Test 20 | public void getOperation_testNotEqualOperations() { 21 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc!=sas"), Matchers.is(Operation.OperationType.NOT_EQUAL)); 22 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc != sas"), Matchers.is(Operation.OperationType.NOT_EQUAL)); 23 | MatcherAssert.assertThat(Operation.OperationType.getOperationType("abc != sas"), Matchers.is(Operation.OperationType.NOT_EQUAL)); 24 | } 25 | */ 26 | } 27 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/templateblocks/PlainTextTemplateBlockTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit Test for {@link PlainTextTemplateBlock}. 9 | */ 10 | public class PlainTextTemplateBlockTest { 11 | 12 | @Test 13 | public void test_getTemplateBlockType() { 14 | MatcherAssert.assertThat(new PlainTextTemplateBlock("").getTemplateBlockType(), Matchers.is(TemplateBlockType.PLAIN_TEXT)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/templateblocks/StaticTemplateBlockTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit Test for {@link StaticTemplateBlock}. 9 | */ 10 | public class StaticTemplateBlockTest { 11 | 12 | @Test 13 | public void test_getTemplateBlockType() { 14 | MatcherAssert.assertThat(new StaticTemplateBlock("").getTemplateBlockType(), Matchers.is(TemplateBlockType.STATIC)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/templateblocks/TemplateBlockBinderTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.templateblocks; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | 7 | /** 8 | * Unit Test for {@link TemplateBlockBinder}. 9 | */ 10 | public class TemplateBlockBinderTest { 11 | 12 | @Test 13 | public void test_getTemplateBlockType() { 14 | MatcherAssert.assertThat(new TemplateBlockBinder("").getTemplateBlockType(), Matchers.is(TemplateBlockType.BINDER)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/testclasses/TestClass1.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.testclasses; 2 | 3 | /** 4 | * Used to test access paths. 5 | */ 6 | public class TestClass1 { 7 | 8 | private final int value = 5; 9 | 10 | public int getValue() { 11 | return value; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /templating/src/test/java/io/toolisticon/aptk/templating/testclasses/TestClass2.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.templating.testclasses; 2 | 3 | /** 4 | * Used to test access paths. 5 | */ 6 | public class TestClass2 { 7 | private final TestClass1 testClass1 = new TestClass1(); 8 | 9 | public TestClass1 getTestClass1() { 10 | return testClass1; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templating/src/test/resources/ComplexTemplateWithAllBlockTypes.expectedResult: -------------------------------------------------------------------------------- 1 | abc 2 | value : 1 3 | include : 1 4 | 8j 5 | abc 6 | def 7 | 8 | !{if asds} 9 | 10 | 11 | value : 2 12 | include : 2 13 | 8j 14 | abc 15 | def 16 | 17 | !{if asds} 18 | 19 | 20 | value : 3 21 | include : 3 22 | 8j 23 | abc 24 | def 25 | 26 | !{if asds} 27 | 28 | 29 | -------------------------------------------------------------------------------- /templating/src/test/resources/ComplexTemplateWithAllBlockTypes.tpl: -------------------------------------------------------------------------------- 1 | abc 2 | !{for name: model.loopValues}value : ${name.value} 3 | !{include resource : '/ComplexTemplateWithAllBlockTypesIncludedTemplate.tpl', model : 'name'}!{/include} 4 | !{if xyz}8j 5 | abc 6 | def 7 | !{static} 8 | !{if asds} 9 | !{/static} 10 | !{/if} 11 | !{/for} -------------------------------------------------------------------------------- /templating/src/test/resources/ComplexTemplateWithAllBlockTypesIncludedTemplate.tpl: -------------------------------------------------------------------------------- 1 | include : ${model.value} -------------------------------------------------------------------------------- /templating/src/test/resources/ComplexTemplateWithControlBlock.expectedResult: -------------------------------------------------------------------------------- 1 | abc 2 | value : 1 3 | value : 2 4 | value : 3 5 | -------------------------------------------------------------------------------- /templating/src/test/resources/ComplexTemplateWithControlBlock.tpl: -------------------------------------------------------------------------------- 1 | abc 2 | !{for name: model.loopValues}value : ${name.value} 3 | !{/for} -------------------------------------------------------------------------------- /templating/src/test/resources/GetControlBlockTemplateStringTestTemplate.expectedResult: -------------------------------------------------------------------------------- 1 | ! 2 | ! 3 | ! 4 | ! 5 | ! 6 | ! 7 | ! 8 | ! 9 | -------------------------------------------------------------------------------- /templating/src/test/resources/GetControlBlockTemplateStringTestTemplate.tpl: -------------------------------------------------------------------------------- 1 | ! 2 | ! 3 | ! 4 | ! 5 | ! 6 | ! 7 | ! 8 | ! 9 | ! -------------------------------------------------------------------------------- /templating/src/test/resources/IfStatementBlockType.expectedResult1: -------------------------------------------------------------------------------- 1 | begin 2 | 2nd 3 | end -------------------------------------------------------------------------------- /templating/src/test/resources/IfStatementBlockType.expectedResult2: -------------------------------------------------------------------------------- 1 | begin 2 | 3rd2 3 | end -------------------------------------------------------------------------------- /templating/src/test/resources/IfStatementBlockType.expectedResult3: -------------------------------------------------------------------------------- 1 | begin 2 | 4th 3 | end -------------------------------------------------------------------------------- /templating/src/test/resources/IfStatementBlockType.tpl: -------------------------------------------------------------------------------- 1 | begin 2 | !{if var == 1}2nd!{elseif var==2}3rd${var}!{else}4th!{/if} 3 | end -------------------------------------------------------------------------------- /templating/src/test/resources/IncludeTemplateBlockTest.expectedResult: -------------------------------------------------------------------------------- 1 | test : test -------------------------------------------------------------------------------- /templating/src/test/resources/IncludeTemplateBlockTest.tpl: -------------------------------------------------------------------------------- 1 | test : ${model.value} -------------------------------------------------------------------------------- /templating/src/test/resources/IncludeTestWithModelAttribute.tpl: -------------------------------------------------------------------------------- 1 | !{include resource:'/IncludeTemplateBlockTest.tpl', model:'model.bridge'} 2 | !{/include} -------------------------------------------------------------------------------- /templating/src/test/resources/IncludeTestWithModelDefinitionInContent.tpl: -------------------------------------------------------------------------------- 1 | !{include resource:'/IncludeTemplateBlockTest.tpl'} 2 | model:model.bridge 3 | !{/include} -------------------------------------------------------------------------------- /templating/src/test/resources/MultipleVariableTextWithoutControlBlock.expectedResult: -------------------------------------------------------------------------------- 1 | To be, or not to be? That is the question— 2 | Whether ’tis nobler in the mind to suffer 3 | The slings and arrows of outrageous fortune, 4 | Or to take arms against a sea of troubles, 5 | And, by opposing, end them? To die, to sleep— 6 | No more—and by a sleep to say we end 7 | The heartache and the thousand natural shocks 8 | That flesh is heir to—’tis a consummation 9 | Devoutly to be wished! To die, to sleep. 10 | To sleep, perchance to dream—ay, there’s the rub, 11 | For in that sleep of death what dreams may come 12 | When we have shuffled off this mortal coil, 13 | Must give us pause. There’s the respect 14 | That makes calamity of so long life. -------------------------------------------------------------------------------- /templating/src/test/resources/MultipleVariableTextWithoutControlBocks.tpl: -------------------------------------------------------------------------------- 1 | To be, or not to be? That is the question— 2 | Whether ’tis ${ model.nobler } in the mind to suffer 3 | The slings and arrows of outrageous fortune, 4 | Or to take arms against a sea of troubles, 5 | And, by opposing, end them? To die, to sleep— 6 | No more—and by a sleep to say we end 7 | The heartache and the thousand natural shocks 8 | That flesh is heir to—’tis a consummation 9 | Devoutly to be ${model.wished}! To die, to sleep. 10 | To sleep, perchance to dream—ay, there’s the rub, 11 | For in that sleep of death what dreams may come 12 | When we have shuffled off this mortal coil, 13 | Must give us pause. There’s the ${ model.pojo.respect } 14 | That makes calamity of so long ${ model.pojo.life }. -------------------------------------------------------------------------------- /templating/src/test/resources/ReadResourceToStringTest.txt: -------------------------------------------------------------------------------- 1 | ABC 2 | DEF 3 | HIJ -------------------------------------------------------------------------------- /templating/src/test/resources/TestTemplateProcessorTemplateFile.tpl: -------------------------------------------------------------------------------- 1 | ${test} -------------------------------------------------------------------------------- /templating/src/test/resources/TestTemplateWithDifferentIfStatements.expectedResult: -------------------------------------------------------------------------------- 1 | first 2 | second 3 | 4 | fourth -------------------------------------------------------------------------------- /templating/src/test/resources/TestTemplateWithDifferentIfStatments.tpl: -------------------------------------------------------------------------------- 1 | !{if xyz}first!{/if} 2 | !{if xyz == true }second!{/if} 3 | !{if xyz != true }third!{/if} 4 | !{if xyz != true || xyz }fourth!{/if} -------------------------------------------------------------------------------- /templating/src/test/resources/TestTemplateWithDifferentVariableTextBlocks.expectedResult: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | 5 5 | 10 6 | 23 7 | YEP23 8 | true -------------------------------------------------------------------------------- /templating/src/test/resources/TestTemplateWithDifferentVariableTextBlocks.tpl: -------------------------------------------------------------------------------- 1 | ${test != null} 2 | ${test.testClass1 != null} 3 | ${test.getTestClass1 != null} 4 | ${test.testClass1.value} 5 | ${test.testClass1.getValue + 5} 6 | ${test.testClass1.getValue + 5 * 4 - 2} 7 | ${'YEP' + (test.testClass1.getValue + 5 * 4 - 2)} 8 | ${test.testClass1.value >= 0 && test.testClass1.value <=10 && test.testClass1.value > -2 && test.testClass1.value <12} -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/ProcessingEnvironmentUtils.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | import io.toolisticon.aptk.common.ToolingProvider; 4 | 5 | import javax.annotation.processing.Filer; 6 | import javax.annotation.processing.Messager; 7 | import javax.annotation.processing.ProcessingEnvironment; 8 | import javax.lang.model.util.Elements; 9 | import javax.lang.model.util.Types; 10 | 11 | /** 12 | * Convenience class to access tools offered by ProcessingEnvironment via {@link ToolingProvider}. 13 | */ 14 | public final class ProcessingEnvironmentUtils { 15 | 16 | /** 17 | * Hidden constructor. 18 | */ 19 | private ProcessingEnvironmentUtils() { 20 | 21 | } 22 | 23 | /** 24 | * Gets Elements tools. 25 | * 26 | * @return the Elements instance 27 | */ 28 | public static Elements getElements() { 29 | return ToolingProvider.getTooling().getElements(); 30 | } 31 | 32 | /** 33 | * Gets Elements tools. 34 | * 35 | * @return the Elements instance 36 | */ 37 | public static Filer getFiler() { 38 | return ToolingProvider.getTooling().getFiler(); 39 | } 40 | 41 | /** 42 | * Gets Types tools. 43 | * 44 | * @return the Types instance 45 | */ 46 | public static Types getTypes() { 47 | return ToolingProvider.getTooling().getTypes(); 48 | } 49 | 50 | /** 51 | * Gets Messager tools. 52 | * 53 | * @return the Messager instance 54 | */ 55 | public static Messager getMessager() { 56 | return ToolingProvider.getTooling().getMessager(); 57 | } 58 | 59 | 60 | /** 61 | * Gets processing environment. 62 | * 63 | * @return The trees instance 64 | */ 65 | public static ProcessingEnvironment getProcessingEnvironment() { 66 | return ToolingProvider.getTooling().getProcessingEnvironment(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/command/Command.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.command; 2 | 3 | import javax.lang.model.element.Element; 4 | 5 | /** 6 | * Command that can be used with fluent validator and filter. 7 | */ 8 | public interface Command { 9 | 10 | void execute(ELEMENT_TYPE element); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/command/CommandWithReturnType.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.command; 2 | 3 | 4 | import javax.lang.model.element.Element; 5 | 6 | /** 7 | * Command that can be used with fluent validator and filter. 8 | */ 9 | public interface CommandWithReturnType { 10 | 11 | TARGET_TYPE execute(ELEMENT_TYPE element); 12 | 13 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommand.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.command.impl; 2 | 3 | import io.toolisticon.aptk.tools.BeanUtils; 4 | import io.toolisticon.aptk.tools.BeanUtils.AttributeResult; 5 | import io.toolisticon.aptk.tools.TypeMirrorWrapper; 6 | import io.toolisticon.aptk.tools.command.CommandWithReturnType; 7 | 8 | import javax.lang.model.element.TypeElement; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * Get all attributes of passed TypeElement. 14 | * attribute = field with adequate getter and setter method 15 | */ 16 | public class GetAttributesCommand implements CommandWithReturnType { 17 | 18 | private final Map resolvedTypeArgumentMap; 19 | 20 | public GetAttributesCommand(Map resolvedTypeArgumentMap) { 21 | this.resolvedTypeArgumentMap = resolvedTypeArgumentMap; 22 | } 23 | 24 | @Override 25 | public AttributeResult[] execute(TypeElement element) { 26 | 27 | return BeanUtils.getAttributes(element); 28 | 29 | } 30 | 31 | public static GetAttributesCommand createCommand(Map resolvedTypeArgumentMap) { 32 | return new GetAttributesCommand(resolvedTypeArgumentMap); 33 | } 34 | 35 | public static GetAttributesCommand createCommand() { 36 | return createCommand(new HashMap<>()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandWithInheritance.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.command.impl; 2 | 3 | import io.toolisticon.aptk.tools.BeanUtils; 4 | import io.toolisticon.aptk.tools.BeanUtils.AttributeResult; 5 | import io.toolisticon.aptk.tools.command.CommandWithReturnType; 6 | 7 | import javax.lang.model.element.TypeElement; 8 | 9 | /** 10 | * Get all attributes of passed TypeElement and it's parents. 11 | * attribute = field with adequate getter and setter method 12 | */ 13 | public class GetAttributesCommandWithInheritance implements CommandWithReturnType { 14 | 15 | public final static GetAttributesCommandWithInheritance INSTANCE = new GetAttributesCommandWithInheritance(); 16 | 17 | @Override 18 | public AttributeResult[] execute(TypeElement element) { 19 | 20 | return BeanUtils.getAttributesWithInheritance(element); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/AbstractBaseCoreMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.corematcher; 2 | 3 | /** 4 | * Abstract base core matcher class. 5 | */ 6 | public class AbstractBaseCoreMatcher { 7 | 8 | private final ValidationMessage defaultValidatorMessage; 9 | 10 | protected AbstractBaseCoreMatcher(ValidationMessage defaultValidatorMessage) { 11 | this.defaultValidatorMessage = defaultValidatorMessage; 12 | } 13 | 14 | protected ValidationMessage getDefaultValidatorMessage() { 15 | return this.defaultValidatorMessage; 16 | } 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/CompilerMessage.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.corematcher; 2 | 3 | /** 4 | * This is the abstract base class 5 | */ 6 | public class CompilerMessage implements ValidationMessage { 7 | 8 | /** 9 | * the message code. 10 | */ 11 | private final String code; 12 | /** 13 | * the message text. 14 | */ 15 | private final String message; 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param code the message code 21 | * @param message the message text 22 | */ 23 | CompilerMessage(String code, String message) { 24 | this.code = code; 25 | this.message = message; 26 | } 27 | 28 | /** 29 | * Gets the code of the message. 30 | * 31 | * @return the message code 32 | */ 33 | public String getCode() { 34 | return this.code; 35 | } 36 | 37 | /** 38 | * Gets the message text. 39 | * 40 | * @return the message text 41 | */ 42 | public String getMessage() { 43 | return message; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/CoreMatchers.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.corematcher; 2 | 3 | /** 4 | * Core Matchers provided by the APTK. 5 | * Deprecated: Please use {@link AptkCoreMatchers} instead. 6 | */ 7 | @Deprecated 8 | public class CoreMatchers extends AptkCoreMatchers{ 9 | } 10 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/PlainValidationMessage.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.corematcher; 2 | 3 | /** 4 | * Plain validation message. 5 | *

6 | * Can be used to create ValidationMessage with message String and optional code. 7 | */ 8 | public class PlainValidationMessage implements ValidationMessage { 9 | 10 | private final String code; 11 | private final String message; 12 | 13 | /** 14 | * Internal constructor. 15 | * 16 | * @param code The massage code 17 | * @param message The message string 18 | */ 19 | private PlainValidationMessage(String code, String message) { 20 | this.code = code; 21 | this.message = message; 22 | } 23 | 24 | 25 | @Override 26 | public String getCode() { 27 | return code; 28 | } 29 | 30 | @Override 31 | public String getMessage() { 32 | return message; 33 | } 34 | 35 | /** 36 | * Convenience method to create validation message without code but a message 37 | * 38 | * @param message the message to use 39 | * @return a PlainValidationMessage instance 40 | */ 41 | public static PlainValidationMessage create(String message) { 42 | return new PlainValidationMessage(null, message); 43 | } 44 | 45 | /** 46 | * Convenience method to create validation message with code and message 47 | * 48 | * @param code the code to use 49 | * @param message the message to use 50 | * @return a PlainValidationMessage instance 51 | */ 52 | public static PlainValidationMessage create(String code, String message) { 53 | return new PlainValidationMessage(code, message); 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/ValidationMessage.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.corematcher; 2 | 3 | /** 4 | * Interface to access message and message code. 5 | */ 6 | public interface ValidationMessage { 7 | 8 | /** 9 | * Gets the code of the message. 10 | * 11 | * @return the message code 12 | */ 13 | String getCode(); 14 | 15 | /** 16 | * Gets the message text. 17 | * 18 | * @return the message text 19 | */ 20 | String getMessage(); 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/corematcher/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the implementation classes for the different kinds of CoreMatchers. 3 | *

4 | * Currently there are the following CoreMatcher types: 5 | *

6 | * - Implicit matchers (no arguments) 7 | * - Is matcher (no arguments like implicit matcher, but changes element type) 8 | * - Characteristic matchers 9 | * -- Inclusive matchers (Matcher none, one, at least one or all characteristics) 10 | * -- Exclusive matchers (Matches none or one characteristic) 11 | */ 12 | package io.toolisticon.aptk.tools.corematcher; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Filter related implementation classes. 3 | */ 4 | package io.toolisticon.aptk.tools.filter; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/TransitionFilters.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter; 2 | 3 | import io.toolisticon.aptk.tools.fluentfilter.impl.ChildElementsTransitionFilter; 4 | import io.toolisticon.aptk.tools.fluentfilter.impl.ElementBasedTransitionFilter; 5 | import io.toolisticon.aptk.tools.fluentfilter.impl.ParentElementTransitionFilter; 6 | import io.toolisticon.aptk.tools.fluentfilter.impl.RemoveDuplicatesTransitionFilter; 7 | import io.toolisticon.aptk.tools.fluentfilter.impl.SuperTypesTransitionFilter; 8 | import io.toolisticon.aptk.tools.fluentfilter.impl.TransitionFilter; 9 | 10 | import javax.lang.model.element.Element; 11 | import javax.lang.model.element.TypeElement; 12 | 13 | /** 14 | * Convenience class to access all given {@link TransitionFilter}. 15 | */ 16 | public final class TransitionFilters { 17 | 18 | /** 19 | * Hidden constructor. 20 | */ 21 | private TransitionFilters() { 22 | 23 | } 24 | 25 | /** 26 | * Transition to all direct childElements. 27 | */ 28 | public final static ElementBasedTransitionFilter CHILD_ELEMENTS = new ChildElementsTransitionFilter(); 29 | /** 30 | * Transition to all direct parentElements. 31 | */ 32 | public final static ElementBasedTransitionFilter PARENT_ELEMENTS = new ParentElementTransitionFilter(); 33 | /** 34 | * Removes all duplicate elements. 35 | * This is not really a transition. 36 | * But it differs from CoreFilters that Elements will be compared with each other. 37 | */ 38 | public final static ElementBasedTransitionFilter REMOVE_DUPLICATES_ELEMENTS = new RemoveDuplicatesTransitionFilter(); 39 | /** 40 | * Transition to all super types (not just the direct parents). 41 | */ 42 | public final static TransitionFilter SUPER_TYPE_ELEMENTS = new SuperTypesTransitionFilter(); 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/ChildElementsTransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import javax.lang.model.element.Element; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Transition to child elements of passed elements. 9 | */ 10 | public class ChildElementsTransitionFilter implements ElementBasedTransitionFilter { 11 | 12 | @Override 13 | public List transition(List elements) { 14 | 15 | List childElements = new ArrayList<>(); 16 | 17 | if (elements != null) { 18 | 19 | for (Element element : elements) { 20 | 21 | childElements.addAll(element.getEnclosedElements()); 22 | 23 | } 24 | 25 | } 26 | 27 | return childElements; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/ElementBasedTransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import javax.lang.model.element.Element; 4 | import java.util.List; 5 | 6 | /** 7 | * Element based transition filter. 8 | */ 9 | public interface ElementBasedTransitionFilter { 10 | 11 | /** 12 | * Does a transition. 13 | * 14 | * @param elements the Elements to apply the transition to 15 | * @return a new list containing the transitions result Elements 16 | */ 17 | List transition(List elements); 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/ParentElementTransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import javax.lang.model.element.Element; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Transition to parent elements of passed elements. 9 | */ 10 | public class ParentElementTransitionFilter implements ElementBasedTransitionFilter { 11 | 12 | @Override 13 | public List transition(List elements) { 14 | 15 | List parentElements = new ArrayList<>(); 16 | 17 | if (elements != null) { 18 | 19 | for (Element element : elements) { 20 | 21 | parentElements.add(element.getEnclosingElement()); 22 | 23 | } 24 | 25 | } 26 | 27 | return parentElements; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/RemoveDuplicatesTransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import javax.lang.model.element.Element; 4 | import java.util.ArrayList; 5 | import java.util.HashSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | /** 10 | * Removes duplicate elements. 11 | */ 12 | public class RemoveDuplicatesTransitionFilter implements ElementBasedTransitionFilter { 13 | 14 | @Override 15 | public List transition(List elements) { 16 | 17 | List filteredElements = new ArrayList<>(); 18 | 19 | if (elements != null) { 20 | 21 | Set elementLookUpTable = new HashSet<>(); 22 | 23 | for (Element element : elements) { 24 | 25 | if (!elementLookUpTable.contains(element)) { 26 | 27 | elementLookUpTable.add(element); 28 | filteredElements.add(element); 29 | 30 | } 31 | 32 | } 33 | 34 | } 35 | 36 | return filteredElements; 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/SuperTypesTransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | 5 | import javax.lang.model.element.TypeElement; 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | /** 11 | * Transition to super types of passed elements. 12 | */ 13 | public class SuperTypesTransitionFilter implements TransitionFilter { 14 | 15 | @Override 16 | public List transition(List elements) { 17 | 18 | List superTypeElements = new ArrayList<>(); 19 | 20 | if (elements != null) { 21 | 22 | for (TypeElement element : elements) { 23 | 24 | superTypeElements.addAll(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElements(element))); 25 | 26 | } 27 | 28 | } 29 | 30 | return superTypeElements; 31 | } 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/impl/TransitionFilter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentfilter.impl; 2 | 3 | import javax.lang.model.element.Element; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | */ 9 | public interface TransitionFilter { 10 | 11 | /** 12 | * Does a transition. 13 | * 14 | * @param elements the Elements to apply the transition to 15 | * @return a new list containing the transitions result Elements 16 | */ 17 | List transition(List elements); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentfilter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package for fluent element filter. 3 | */ 4 | package io.toolisticon.aptk.tools.fluentfilter; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorState.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentvalidator.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This class stores the state of the validation. 8 | */ 9 | public class FluentValidatorState { 10 | 11 | private boolean validationResult = true; 12 | private List validatorMessages = new ArrayList<>(); 13 | 14 | public FluentValidatorState() { 15 | 16 | } 17 | 18 | /** 19 | * Adds a message. 20 | * 21 | * @param validatorMessage the validator message 22 | */ 23 | public void addMessage(FluentValidatorMessage validatorMessage) { 24 | this.validatorMessages.add(validatorMessage); 25 | } 26 | 27 | /** 28 | * Gets the validation result. 29 | * 30 | * @return true if validation was successful, otherwise false. 31 | */ 32 | public boolean getValidationResult() { 33 | return validationResult; 34 | } 35 | 36 | /** 37 | * Set the result to failed. 38 | */ 39 | public void setAsFailedValidation() { 40 | validationResult = false; 41 | } 42 | 43 | /** 44 | * Issues all messages. 45 | */ 46 | public void issueMessages() { 47 | 48 | for (FluentValidatorMessage message : validatorMessages) { 49 | message.issueMessage(); 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentvalidator/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal implementation classes for fluent validator. 3 | */ 4 | package io.toolisticon.aptk.tools.fluentvalidator.impl; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/fluentvalidator/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package for fluent element validator. 3 | */ 4 | package io.toolisticon.aptk.tools.fluentvalidator; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generators/SimpleJavaWriter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generators; 2 | 3 | import javax.tools.JavaFileObject; 4 | import java.io.IOException; 5 | 6 | 7 | /** 8 | * A Simple java writer. 9 | */ 10 | public class SimpleJavaWriter extends FileObjectSimpleWriter { 11 | 12 | 13 | public SimpleJavaWriter(JavaFileObject fileObject) throws IOException { 14 | super(fileObject); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generators/SimpleResourceWriter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generators; 2 | 3 | import javax.tools.FileObject; 4 | import java.io.IOException; 5 | 6 | /** 7 | * Simple helper class to create a file and to add some content by appending. 8 | * This can be very useful for the creation of text based resource files. 9 | */ 10 | 11 | public class SimpleResourceWriter extends FileObjectSimpleWriter { 12 | 13 | 14 | public SimpleResourceWriter(FileObject fileObject) throws IOException { 15 | super(fileObject); 16 | } 17 | 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generators/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains utility classes to read and create resource and java code files. 3 | */ 4 | package io.toolisticon.aptk.tools.generators; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generics/GenericType.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generics; 2 | 3 | import javax.lang.model.type.TypeMirror; 4 | 5 | /** 6 | * This class represents a generic type or a generic type based type parameter. 7 | */ 8 | public class GenericType implements GenericTypeParameter { 9 | 10 | private final TypeMirror rawType; 11 | private final GenericTypeParameter[] typeParameters; 12 | 13 | /** 14 | * Constructor. 15 | * 16 | * @param rawType the raw type of the generic type 17 | * @param typeParameters the type parameters of the generic type (wildcards and generic types) 18 | * @param The generic type parameter type 19 | */ 20 | @SafeVarargs 21 | public GenericType(TypeMirror rawType, T... typeParameters) { 22 | this.rawType = rawType; 23 | this.typeParameters = typeParameters; 24 | } 25 | 26 | /** 27 | * Gets the raw type. 28 | * 29 | * @return the raw type 30 | */ 31 | public TypeMirror getRawType() { 32 | return rawType; 33 | } 34 | 35 | /** 36 | * Gets the type parameters. 37 | * 38 | * @return the type parameters (wildcards and generic types) 39 | */ 40 | public GenericTypeParameter[] getTypeParameters() { 41 | return typeParameters; 42 | } 43 | 44 | /** 45 | * Convenience method to check if there are type parameters. 46 | * 47 | * @return true if there are type parameters, otherwise false 48 | */ 49 | public boolean hasTypeParameters() { 50 | return typeParameters != null && typeParameters.length > 0; 51 | } 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public GenericTypeKind getType() { 58 | return GenericTypeKind.GENERIC_TYPE; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generics/GenericTypeKind.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generics; 2 | 3 | /** 4 | * Enum to determine if a {@link GenericTypeParameter} is a {@link GenericTypeWildcard} or {@link GenericType}. 5 | */ 6 | public enum GenericTypeKind { 7 | /** 8 | * Defines a wildcard type parameter. 9 | */ 10 | WILDCARD, 11 | /** 12 | * Defines a generic type type parameter. 13 | */ 14 | GENERIC_TYPE 15 | } 16 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generics/GenericTypeParameter.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generics; 2 | 3 | /** 4 | * Type parameters in generic classes can contain two different kind of declaration: Generic types or wildcards. 5 | *

6 | * This interface is helping to determine the two different kinds. 7 | */ 8 | public interface GenericTypeParameter { 9 | 10 | /** 11 | * Gets the kind of the type parameter. 12 | * 13 | * @return the type of the type parameter 14 | */ 15 | GenericTypeKind getType(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/generics/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains classes to support generic type checks. 3 | */ 4 | package io.toolisticon.aptk.tools.generics; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/BaseMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher; 2 | 3 | import javax.lang.model.element.Element; 4 | 5 | /** 6 | * BaseMatcher flag interface. 7 | * Has no methods. 8 | */ 9 | public interface BaseMatcher { 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/CriteriaMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher; 2 | 3 | import javax.lang.model.element.Element; 4 | 5 | /** 6 | * Matcher that checks if passed criteria is fulfilled 7 | */ 8 | public interface CriteriaMatcher extends BaseMatcher{ 9 | 10 | /** 11 | * Applies matcher to element to determine if element matches a criteria or not. 12 | * 13 | * @param element the element to check 14 | * @param toCheckFor the criteria to check for 15 | * @return true if the element matches the passed criteria, otherwise false 16 | */ 17 | boolean checkForMatchingCharacteristic(E element, T toCheckFor); 18 | 19 | /** 20 | * Creates a string representation for the passed criteria. 21 | * 22 | * @param toGetStringRepresentationFor the criteria to get a string representation for. 23 | * @return the string representation 24 | */ 25 | String getStringRepresentationOfPassedCharacteristic(T toGetStringRepresentationFor); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/ImplicitMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher; 2 | 3 | import javax.lang.model.element.Element; 4 | 5 | /** 6 | * Matcher for an implicit criteria. 7 | * 8 | * @param The Element type of the matcher 9 | */ 10 | public interface ImplicitMatcher extends BaseMatcher { 11 | 12 | /** 13 | * Checks if element matches implicit criteria. 14 | * @param element the element to check 15 | * @return true, if element matches implicit criteria, otherwise false. 16 | */ 17 | boolean check(E element); 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByAnnotationMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.Element; 6 | import java.lang.annotation.Annotation; 7 | 8 | /** 9 | * Class for checking existence of one annotation on an element. 10 | */ 11 | public class ByAnnotationMatcher implements CriteriaMatcher> { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public String getStringRepresentationOfPassedCharacteristic(Class toGetStringRepresentationFor) { 18 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.getCanonicalName() : null; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public boolean checkForMatchingCharacteristic(Element element, Class toCheckFor) { 26 | return element != null && toCheckFor != null && element.getAnnotation(toCheckFor) != null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByElementKindMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.Element; 6 | import javax.lang.model.element.ElementKind; 7 | 8 | /** 9 | * Class for matching {@link javax.lang.model.element.ElementKind}. 10 | */ 11 | public class ByElementKindMatcher implements CriteriaMatcher { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public boolean checkForMatchingCharacteristic(Element element, ElementKind toCheckFor) { 18 | return (element != null && toCheckFor != null) && element.getKind().equals(toCheckFor); 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public String getStringRepresentationOfPassedCharacteristic(ElementKind toGetStringRepresentationFor) { 26 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.name() : null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByModifierMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.Element; 6 | import javax.lang.model.element.Modifier; 7 | 8 | /** 9 | * Class for matching {@link Modifier}. 10 | */ 11 | public class ByModifierMatcher implements CriteriaMatcher { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public boolean checkForMatchingCharacteristic(Element element, Modifier toCheckFor) { 18 | return (element != null && toCheckFor != null) && element.getModifiers().contains(toCheckFor); 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public String getStringRepresentationOfPassedCharacteristic(Modifier toGetStringRepresentationFor) { 26 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.name() : null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByNameMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.Element; 6 | 7 | /** 8 | * Class for checking for find matching elements by simple name. 9 | */ 10 | public class ByNameMatcher implements CriteriaMatcher { 11 | 12 | /** 13 | * {@inheritDoc} 14 | */ 15 | @Override 16 | public boolean checkForMatchingCharacteristic(Element element, String toCheckFor) { 17 | return (element != null && toCheckFor != null) && element.getSimpleName().toString().equals(toCheckFor); 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 25 | return toGetStringRepresentationFor; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByNameRegexMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.Element; 6 | import java.util.regex.Pattern; 7 | 8 | /** 9 | * Class for checking for find matching elements by name and regular expressions. 10 | */ 11 | public class ByNameRegexMatcher implements CriteriaMatcher { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public boolean checkForMatchingCharacteristic(Element element, String toCheckFor) { 18 | if (element != null && toCheckFor != null) { 19 | 20 | Pattern pattern = Pattern.compile(toCheckFor); 21 | return pattern.matcher(element.getSimpleName().toString()).matches(); 22 | 23 | } 24 | return false; 25 | } 26 | 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | @Override 31 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 32 | return toGetStringRepresentationFor; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByNestingKindMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.NestingKind; 6 | import javax.lang.model.element.TypeElement; 7 | 8 | /** 9 | * Class for checking for NestingKind of TypeElement. 10 | */ 11 | public class ByNestingKindMatcher implements CriteriaMatcher { 12 | 13 | @Override 14 | public boolean checkForMatchingCharacteristic(TypeElement element, NestingKind toCheckFor) { 15 | return element.getNestingKind() == toCheckFor; 16 | } 17 | 18 | @Override 19 | public String getStringRepresentationOfPassedCharacteristic(NestingKind toGetStringRepresentationFor) { 20 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.toString() : null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByNumberOfParametersMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 4 | 5 | import javax.lang.model.element.ExecutableElement; 6 | 7 | public class ByNumberOfParametersMatcher implements CriteriaMatcher { 8 | 9 | /** 10 | * {@inheritDoc} 11 | */ 12 | @Override 13 | public boolean checkForMatchingCharacteristic(ExecutableElement element, Integer toCheckFor) { 14 | return (element != null && toCheckFor != null) && element.getParameters().size() == toCheckFor; 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public String getStringRepresentationOfPassedCharacteristic(Integer toGetStringRepresentationFor) { 22 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.toString() : null; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByPackageNameMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | import javax.lang.model.element.ElementKind; 8 | import javax.lang.model.element.PackageElement; 9 | 10 | /** 11 | * Matcher class to check if (enclosing) package element names are equal 12 | */ 13 | public class ByPackageNameMatcher implements CriteriaMatcher { 14 | 15 | /** 16 | * {@inheritDoc} 17 | */ 18 | @Override 19 | public boolean checkForMatchingCharacteristic(Element element, String toCheckFor) { 20 | 21 | // return false if either one input parameter is null 22 | if (element == null || toCheckFor == null) { 23 | return false; 24 | } 25 | 26 | PackageElement packageElement = ElementKind.PACKAGE.equals(element.getKind()) ? (PackageElement) element : ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); 27 | return toCheckFor.equals(packageElement.getQualifiedName().toString()); 28 | 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 36 | return toGetStringRepresentationFor; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeFqnMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Matcher for raw types. 10 | */ 11 | public class ByRawTypeFqnMatcher implements CriteriaMatcher { 12 | 13 | public ByRawTypeFqnMatcher() { 14 | super(); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public boolean checkForMatchingCharacteristic(Element element, String toCheckFor) { 22 | 23 | if (element == null || toCheckFor == null) { 24 | return false; 25 | } 26 | 27 | // cast to executable element for further checks 28 | 29 | return TypeUtils.TypeComparison.isErasedTypeEqual(element.asType(), TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor)); 30 | 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | @Override 37 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 38 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor : null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Matcher for raw types. 10 | */ 11 | public class ByRawTypeMatcher implements CriteriaMatcher { 12 | 13 | public ByRawTypeMatcher() { 14 | super(); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public boolean checkForMatchingCharacteristic(Element element, Class toCheckFor) { 22 | 23 | if (element == null || toCheckFor == null) { 24 | return false; 25 | } 26 | 27 | // cast to executable element for further checks 28 | 29 | return TypeUtils.TypeComparison.isErasedTypeEqual(element.asType(), TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor)); 30 | 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | @Override 37 | public String getStringRepresentationOfPassedCharacteristic(Class toGetStringRepresentationFor) { 38 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.getCanonicalName() : null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeFqnMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.ExecutableElement; 7 | 8 | /** 9 | * Checks if Executable Element has aspecific return type. 10 | */ 11 | public class ByReturnTypeFqnMatcher implements CriteriaMatcher { 12 | 13 | public ByReturnTypeFqnMatcher() { 14 | super(); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public boolean checkForMatchingCharacteristic(ExecutableElement element, String toCheckFor) { 22 | 23 | if (element == null || toCheckFor == null) { 24 | return false; 25 | } 26 | 27 | // check if number of parameters is the same 28 | return TypeUtils.TypeComparison.isTypeEqual(element.getReturnType(), TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor)); 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 36 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor : ""; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.ExecutableElement; 7 | 8 | /** 9 | * Checks if Executable Element has aspecific return type. 10 | */ 11 | public class ByReturnTypeMatcher implements CriteriaMatcher { 12 | 13 | public ByReturnTypeMatcher() { 14 | super(); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public boolean checkForMatchingCharacteristic(ExecutableElement element, Class toCheckFor) { 22 | 23 | if (element == null || toCheckFor == null) { 24 | return false; 25 | } 26 | 27 | // check if number of parameters is the same 28 | return TypeUtils.TypeComparison.isTypeEqual(element.getReturnType(), TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor)); 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public String getStringRepresentationOfPassedCharacteristic(Class toGetStringRepresentationFor) { 36 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.getCanonicalName() : ""; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMirrorMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.ExecutableElement; 7 | import javax.lang.model.type.TypeMirror; 8 | 9 | /** 10 | * Checks if Executable Element has aspecific return type. 11 | */ 12 | public class ByReturnTypeMirrorMatcher implements CriteriaMatcher { 13 | 14 | public ByReturnTypeMirrorMatcher() { 15 | super(); 16 | } 17 | 18 | /** 19 | * {@inheritDoc} 20 | */ 21 | @Override 22 | public boolean checkForMatchingCharacteristic(ExecutableElement element, TypeMirror toCheckFor) { 23 | 24 | if (element == null || toCheckFor == null) { 25 | return false; 26 | } 27 | 28 | // check if number of parameters is the same 29 | return TypeUtils.TypeComparison.isTypeEqual(element.getReturnType(), toCheckFor); 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public String getStringRepresentationOfPassedCharacteristic(TypeMirror toGetStringRepresentationFor) { 37 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.toString() : ""; 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/HasNoParametersMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 4 | 5 | import javax.lang.model.element.ExecutableElement; 6 | 7 | /** 8 | * Implicit matcher that checks if a passed ExecutableElement has no arguments. 9 | */ 10 | public class HasNoParametersMatcher implements ImplicitMatcher { 11 | 12 | @Override 13 | public boolean check(ExecutableElement element) { 14 | return element != null && element.getParameters().size() == 0; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/HasNoThrownTypesMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 4 | 5 | import javax.lang.model.element.ExecutableElement; 6 | 7 | /** 8 | * Implicit matcher that checks if a passed ExecutableElement has no throws declaration. 9 | */ 10 | public class HasNoThrownTypesMatcher implements ImplicitMatcher { 11 | 12 | @Override 13 | public boolean check(ExecutableElement element) { 14 | return element != null && element.getThrownTypes().size() == 0; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/HasVoidReturnTypeMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.ExecutableElement; 7 | 8 | /** 9 | * Implicit matcher that checks if a passed ExecutableElement has void return type. 10 | */ 11 | public class HasVoidReturnTypeMatcher implements ImplicitMatcher { 12 | 13 | @Override 14 | public boolean check(ExecutableElement element) { 15 | return element != null && TypeUtils.CheckTypeKind.isVoid(element.getReturnType()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsAnnotationTypeMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an annotation. 11 | */ 12 | public class IsAnnotationTypeMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isAnnotation(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToFqnMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Matcher to check if Type Element is assignable to passed class. 10 | */ 11 | public class IsAssignableToFqnMatcher implements CriteriaMatcher { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public String getStringRepresentationOfPassedCharacteristic(String toGetStringRepresentationFor) { 18 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor : null; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public boolean checkForMatchingCharacteristic(Element element, String toCheckFor) { 26 | return element != null && toCheckFor != null && TypeUtils.getTypes() 27 | .isAssignable( 28 | element.asType(), 29 | TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor) 30 | ); 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Matcher to check if Type Element is assignable to passed class. 10 | */ 11 | public class IsAssignableToMatcher implements CriteriaMatcher { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public String getStringRepresentationOfPassedCharacteristic(Class toGetStringRepresentationFor) { 18 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.getCanonicalName() : null; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public boolean checkForMatchingCharacteristic(Element element, Class toCheckFor) { 26 | return element != null && toCheckFor != null && TypeUtils.getTypes() 27 | .isAssignable( 28 | element.asType(), 29 | TypeUtils.TypeRetrieval.getTypeMirror(toCheckFor.getCanonicalName()) 30 | ); 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToTypeMirrorMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.TypeUtils; 4 | import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | import javax.lang.model.type.TypeMirror; 8 | 9 | /** 10 | * Matcher to check if Type Element is assignable to passed class. 11 | */ 12 | public class IsAssignableToTypeMirrorMatcher implements CriteriaMatcher { 13 | 14 | /** 15 | * {@inheritDoc} 16 | */ 17 | @Override 18 | public String getStringRepresentationOfPassedCharacteristic(TypeMirror toGetStringRepresentationFor) { 19 | return toGetStringRepresentationFor != null ? toGetStringRepresentationFor.toString() : null; 20 | } 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public boolean checkForMatchingCharacteristic(Element element, TypeMirror toCheckFor) { 27 | return element != null && toCheckFor != null && TypeUtils.getTypes() 28 | .isAssignable( 29 | element.asType(), 30 | toCheckFor 31 | ); 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsAttributeFieldMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.BeanUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.ElementKind; 7 | import javax.lang.model.element.VariableElement; 8 | 9 | /** 10 | * Matcher to check if field is an attribute. 11 | * Field must not be static. 12 | * Getter must not be static nor abstract, must return fields type and take no parameters 13 | * Setter must not be static nor abstract, must have void return type and one parameter of fields type 14 | */ 15 | public class IsAttributeFieldMatcher implements ImplicitMatcher { 16 | 17 | @Override 18 | public boolean check(VariableElement element) { 19 | 20 | if (element == null || element.getKind() != ElementKind.FIELD) { 21 | return false; 22 | } 23 | 24 | return BeanUtils.isAttribute(element); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsClassMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a class. 11 | */ 12 | public class IsClassMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isClass(element); 17 | } 18 | 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsConstructorMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a constructor. 11 | */ 12 | public class IsConstructorMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isConstructor(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsEnumMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an enum. 11 | */ 12 | public class IsEnumMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isEnum(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsExecutableElementMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Implicit matcher that checks if a passed element is an ExecutableElement. 10 | */ 11 | public class IsExecutableElementMatcher implements ImplicitMatcher { 12 | 13 | @Override 14 | public boolean check(ELEMENT element) { 15 | return ElementUtils.CastElement.isExecutableElement(element); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsFieldMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a field. 11 | */ 12 | public class IsFieldMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isField(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsGetterMethodMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; 4 | import io.toolisticon.aptk.tools.fluentvalidator.FluentElementValidator; 5 | import io.toolisticon.aptk.tools.TypeUtils; 6 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 7 | 8 | import javax.lang.model.element.ExecutableElement; 9 | import javax.lang.model.element.Modifier; 10 | import javax.lang.model.type.TypeMirror; 11 | 12 | public class IsGetterMethodMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ExecutableElement element) { 16 | 17 | if (element == null) { 18 | return false; 19 | } 20 | 21 | if (!FluentElementValidator.createFluentElementValidator(element) 22 | .applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC) 23 | .applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.STATIC, Modifier.ABSTRACT) 24 | .applyValidator(AptkCoreMatchers.HAS_NO_PARAMETERS) 25 | .applyInvertedValidator(AptkCoreMatchers.HAS_VOID_RETURN_TYPE) 26 | .justValidate() 27 | ) { 28 | return false; 29 | } 30 | 31 | TypeMirror returnType = element.getReturnType(); 32 | 33 | 34 | String methodName = element.getSimpleName().toString(); 35 | 36 | return methodName.startsWith("get") || 37 | (TypeUtils.TypeComparison.isTypeEqual(returnType, TypeUtils.TypeRetrieval.getTypeMirror(boolean.class)) 38 | && ((methodName.startsWith("is") || methodName.startsWith("has")))); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsInterfaceMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an interface. 11 | */ 12 | public class IsInterfaceMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isInterface(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsMethodMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a method. 11 | */ 12 | public class IsMethodMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isMethod(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageElementMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | 10 | /** 11 | * Implicit matcher that checks if a passed element is an PackageElement. 12 | */ 13 | public class IsPackageElementMatcher implements ImplicitMatcher { 14 | 15 | @Override 16 | public boolean check(ELEMENT element) { 17 | return ElementUtils.CastElement.isPackageElement(element); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a package. 11 | */ 12 | public class IsPackageMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isPackage(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsParameterMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an Parameter. 11 | */ 12 | public class IsParameterMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isParameter(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsRecordMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an enum. 11 | */ 12 | public class IsRecordMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isRecord(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsSetterMethodMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; 4 | import io.toolisticon.aptk.tools.fluentvalidator.FluentElementValidator; 5 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 6 | 7 | import javax.lang.model.element.ExecutableElement; 8 | import javax.lang.model.element.Modifier; 9 | 10 | public class IsSetterMethodMatcher implements ImplicitMatcher { 11 | 12 | @Override 13 | public boolean check(ExecutableElement element) { 14 | 15 | if (element == null) { 16 | return false; 17 | } 18 | 19 | return FluentElementValidator.createFluentElementValidator(element) 20 | .applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC) 21 | .applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.STATIC, Modifier.ABSTRACT) 22 | .applyValidator(AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS).hasOneOf(1) 23 | .applyValidator(AptkCoreMatchers.HAS_VOID_RETURN_TYPE) 24 | .applyValidator(AptkCoreMatchers.BY_REGEX_NAME).hasOneOf("set.*") 25 | .justValidate(); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeElementMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is an TypeElement. 11 | */ 12 | public class IsTypeElementMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CastElement.isTypeElement(element); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualFqnMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | /** 4 | * Matcher to check if Type Element's type matches to passed class. 5 | */ 6 | public class IsTypeEqualFqnMatcher extends ByRawTypeFqnMatcher { 7 | 8 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | /** 4 | * Matcher to check if Type Element's type matches to passed class. 5 | */ 6 | public class IsTypeEqualMatcher extends ByRawTypeMatcher { 7 | 8 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | 9 | /** 10 | * Implicit matcher that checks if a passed element is a type (i.e of Kind CLASS, INTERFACE or RECORD). 11 | */ 12 | public class IsTypeMatcher implements ImplicitMatcher { 13 | 14 | @Override 15 | public boolean check(ELEMENT element) { 16 | return ElementUtils.CheckKindOfElement.isClass(element) 17 | || ElementUtils.CheckKindOfElement.isInterface(element) 18 | || ElementUtils.CheckKindOfElement.isEnum(element) 19 | || ElementUtils.CheckKindOfElement.isAnnotation(element) 20 | || ElementUtils.CheckKindOfElement.isRecord(element); 21 | } 22 | 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/IsVariableElementMatcher.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.ElementUtils; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Implicit matcher that checks if a passed element is an VariableElement. 10 | */ 11 | public class IsVariableElementMatcher implements ImplicitMatcher { 12 | 13 | @Override 14 | public boolean check(ELEMENT element) { 15 | return ElementUtils.CastElement.isVariableElement(element); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementations for all supported CoreMatchers. 3 | */ 4 | package io.toolisticon.aptk.tools.matcher.impl; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/matcher/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package that contains all core matchers provided by the toolkit. 3 | * This matchers are used within validators and filters. 4 | */ 5 | package io.toolisticon.aptk.tools.matcher; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the {@link io.toolisticon.aptk.tools.AbstractAnnotationProcessor} 3 | * and all utility classes offered by the annotation processor toolkit. 4 | */ 5 | package io.toolisticon.aptk.tools; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/validator/AbstractBaseValidator.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.validator; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.ValidationMessage; 4 | 5 | /** 6 | * Base interface for validators. 7 | */ 8 | public class AbstractBaseValidator { 9 | 10 | private final ValidationMessage defaultMessage; 11 | 12 | 13 | public AbstractBaseValidator(ValidationMessage defaultMessage) { 14 | this.defaultMessage = defaultMessage; 15 | } 16 | 17 | 18 | public ValidationMessage getDefaultMessage() { 19 | return this.defaultMessage; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/validator/ImplicitValidator.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.validator; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.ValidationMessage; 4 | import io.toolisticon.aptk.tools.matcher.ImplicitMatcher; 5 | 6 | import javax.lang.model.element.Element; 7 | 8 | /** 9 | * Validator to check implicit criteria. 10 | */ 11 | public class ImplicitValidator> extends AbstractBaseValidator { 12 | 13 | private final MATCHER matcher; 14 | 15 | public ImplicitValidator(MATCHER matcher, ValidationMessage defaultMessage) { 16 | super(defaultMessage); 17 | this.matcher = matcher; 18 | } 19 | 20 | public boolean validate(E element) { 21 | return this.matcher.check(element); 22 | } 23 | 24 | public MATCHER getMatcher() { 25 | return matcher; 26 | } 27 | 28 | 29 | } -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/validator/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package that contains all core validators provided by the toolkit. 3 | * This validators are internally using matchers. 4 | */ 5 | package io.toolisticon.aptk.tools.validator; -------------------------------------------------------------------------------- /tools/src/main/java/io/toolisticon/aptk/tools/wrapper/VariableElementWrapper.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.wrapper; 2 | 3 | import javax.lang.model.element.VariableElement; 4 | 5 | /** 6 | * Wrapper for variable Element 7 | */ 8 | public class VariableElementWrapper extends ElementWrapper{ 9 | 10 | protected VariableElementWrapper(VariableElement variableElement) { 11 | super(variableElement); 12 | } 13 | 14 | public Object getConstantValue() { 15 | return this.element.getConstantValue(); 16 | } 17 | 18 | /** 19 | * Wraps a VariableElement. 20 | * Will throw IllegalArgumentException if passed element is null. 21 | * @param variableElement the element to wrap 22 | * @return a wrapper instance 23 | */ 24 | public static VariableElementWrapper wrap(VariableElement variableElement) { 25 | return new VariableElementWrapper(variableElement); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/DummyValidatorMessage.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.ValidationMessage; 4 | 5 | /** 6 | * Validator message used in tests. 7 | */ 8 | public class DummyValidatorMessage implements ValidationMessage { 9 | 10 | public final static DummyValidatorMessage DUMMY_MESSAGE = new DummyValidatorMessage("DUMMY", "DUMMY_CODE"); 11 | 12 | 13 | private final String message; 14 | 15 | private final String code; 16 | 17 | public DummyValidatorMessage(String message, String code) { 18 | this.message = message; 19 | this.code = code; 20 | } 21 | 22 | @Override 23 | public String getCode() { 24 | return code; 25 | } 26 | 27 | @Override 28 | public String getMessage() { 29 | return "[" + code + "]: " + message; 30 | } 31 | 32 | public static DummyValidatorMessage create(String message, String code) { 33 | return new DummyValidatorMessage(message, code); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/FilerUtilsTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | import io.toolisticon.aptk.tools.generators.FileObjectUtilsTestAnnotationProcessor; 4 | import io.toolisticon.cute.CompileTestBuilder; 5 | import io.toolisticon.cute.CompileTestBuilderApi; 6 | import io.toolisticon.cute.JavaFileObjectUtils; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import javax.tools.StandardLocation; 11 | 12 | public class FilerUtilsTest { 13 | 14 | 15 | @Before 16 | public void init() { 17 | MessagerUtils.setPrintMessageCodes(true); 18 | } 19 | 20 | private CompileTestBuilderApi.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder 21 | .compilationTest() 22 | .addSources(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); 23 | 24 | 25 | @Test 26 | public void testValidUsage() { 27 | 28 | compilationTestBuilder.addProcessors(FileObjectUtilsTestAnnotationProcessor.class) 29 | .addSources(JavaFileObjectUtils.readFromResource("/testcases/generators/FilerUtilsTestClass.java")) 30 | .compilationShouldSucceed() 31 | .expectThatFileObjectExists(StandardLocation.CLASS_OUTPUT, "", "testOutput.txt", JavaFileObjectUtils.readFromResource("/testcases/generators/expectedResult.txt")) 32 | .executeTest(); 33 | 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/FilterTestAnnotation1.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(value = {ElementType.METHOD}) 10 | public @interface FilterTestAnnotation1 { 11 | String value() default "YES"; 12 | } 13 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/FilterTestAnnotation2.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(value = {ElementType.METHOD}) 10 | public @interface FilterTestAnnotation2 { 11 | } 12 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/IsRepeatable.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | 4 | import java.lang.annotation.Repeatable; 5 | 6 | @Repeatable(IsRepeatableWrapper.class) 7 | public @interface IsRepeatable { 8 | String value() default ""; 9 | } 10 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/IsRepeatableWrapper.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools; 2 | 3 | public @interface IsRepeatableWrapper { 4 | IsRepeatable[] value(); 5 | } 6 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/annotationutilstestclasses/ClassArrayAttributeAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.annotationutilstestclasses; 2 | 3 | 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Test annotation for a class array annotation attribute. 11 | */ 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target(value = ElementType.METHOD) 14 | public @interface ClassArrayAttributeAnnotation { 15 | 16 | Class[] value() default {}; 17 | 18 | Class[] classArrayAttribute() default {}; 19 | 20 | } -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/annotationutilstestclasses/ClassAttributeAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.annotationutilstestclasses; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Test annotation for a class annotation attribute. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(value = {ElementType.METHOD,ElementType.TYPE}) 13 | public @interface ClassAttributeAnnotation { 14 | 15 | Class value() default Void.class; 16 | 17 | Class classAttribute() default Void.class; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/annotationutilstestclasses/DefaultValueAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.annotationutilstestclasses; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Test annotation to test extraction of default values. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(value = ElementType.TYPE) 13 | public @interface DefaultValueAnnotation { 14 | long value() default 5L; 15 | long mandatoryValue(); 16 | } 17 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/annotationutilstestclasses/NoAttributeAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.annotationutilstestclasses; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation that doesn't have attributes. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(value = ElementType.TYPE) 13 | public @interface NoAttributeAnnotation { 14 | } 15 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorStateTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.fluentvalidator.impl; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | import org.mockito.Mockito; 7 | 8 | /** 9 | * Unit test for {@link FluentValidatorState} 10 | */ 11 | public class FluentValidatorStateTest { 12 | 13 | 14 | @Test 15 | public void testSetFailingResult() { 16 | 17 | FluentValidatorState unit = new FluentValidatorState(); 18 | 19 | MatcherAssert.assertThat(unit.getValidationResult(), Matchers.is(true)); 20 | 21 | unit.setAsFailedValidation(); 22 | MatcherAssert.assertThat(unit.getValidationResult(), Matchers.is(false)); 23 | 24 | } 25 | 26 | @Test 27 | public void testAddAndIssueMessages() { 28 | FluentValidatorMessage fluentValidatorMessage1 = Mockito.mock(FluentValidatorMessage.class); 29 | FluentValidatorMessage fluentValidatorMessage2 = Mockito.mock(FluentValidatorMessage.class); 30 | 31 | FluentValidatorState unit = new FluentValidatorState(); 32 | unit.addMessage(fluentValidatorMessage1); 33 | unit.addMessage(fluentValidatorMessage2); 34 | 35 | unit.issueMessages(); 36 | Mockito.verify(fluentValidatorMessage1, Mockito.times(1)).issueMessage(); 37 | Mockito.verify(fluentValidatorMessage2, Mockito.times(1)).issueMessage(); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/generators/FileObjectUtilsTestAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generators; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(value = ElementType.METHOD) 10 | public @interface FileObjectUtilsTestAnnotation { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/generators/FileObjectUtilsTestAnnotationProcessor.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.generators; 2 | 3 | import io.toolisticon.aptk.tools.AbstractAnnotationProcessor; 4 | import io.toolisticon.aptk.tools.FilerUtils; 5 | import io.toolisticon.aptk.tools.MessagerUtils; 6 | 7 | import javax.annotation.processing.RoundEnvironment; 8 | import javax.annotation.processing.SupportedAnnotationTypes; 9 | import javax.lang.model.element.Element; 10 | import javax.lang.model.element.TypeElement; 11 | import java.util.Set; 12 | 13 | /** 14 | * Test annotation processor for testing {@link FilerUtils}. 15 | */ 16 | 17 | @SupportedAnnotationTypes( 18 | "io.toolisticon.aptk.tools.generators.FileObjectUtilsTestAnnotation") 19 | public class FileObjectUtilsTestAnnotationProcessor extends AbstractAnnotationProcessor { 20 | 21 | private SimpleResourceWriter simpleResourceWriter = null; 22 | 23 | 24 | @Override 25 | public boolean processAnnotations(Set annotations, RoundEnvironment roundEnv) { 26 | 27 | try { 28 | for (Element element : roundEnv.getElementsAnnotatedWith(FileObjectUtilsTestAnnotation.class)) { 29 | 30 | if (simpleResourceWriter == null) { 31 | 32 | simpleResourceWriter = FilerUtils.createResource("testOutput.txt"); 33 | 34 | } 35 | 36 | simpleResourceWriter.append(element.getSimpleName().toString() + System.lineSeparator()); 37 | 38 | } 39 | } catch (Exception e) { 40 | 41 | MessagerUtils.error(null, "Wasn't able to use SimpleResourceWriter without error"); 42 | 43 | } finally { 44 | try { 45 | simpleResourceWriter.close(); 46 | 47 | } catch (Exception e) { 48 | 49 | } 50 | } 51 | 52 | return false; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/internal/UtilitiesTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.internal; 2 | 3 | import io.toolisticon.aptk.tools.Utilities; 4 | import org.hamcrest.MatcherAssert; 5 | import org.hamcrest.Matchers; 6 | import org.junit.Test; 7 | 8 | import java.util.Arrays; 9 | import java.util.Set; 10 | 11 | /** 12 | * Unit test class for {@link Utilities}. 13 | */ 14 | public class UtilitiesTest { 15 | 16 | @Test 17 | public void test_ConvertArrayToSet_nullValuedParameter() { 18 | 19 | MatcherAssert.assertThat(Utilities.convertArrayToSet(null), Matchers.nullValue()); 20 | 21 | } 22 | 23 | @Test 24 | public void test_ConvertArrayToSet_emptyArrayParameter() { 25 | 26 | MatcherAssert.assertThat(Utilities.convertArrayToSet(new String[0]), Matchers.hasSize(0)); 27 | 28 | } 29 | 30 | @Test 31 | public void test_ConvertArrayToSet_happyPath() { 32 | 33 | String[] testArray = {"a", "b", "c"}; 34 | 35 | MatcherAssert.assertThat(Utilities.convertArrayToSet(testArray), Matchers.containsInAnyOrder("a", "b", "c")); 36 | 37 | 38 | } 39 | 40 | @Test 41 | public void test_ConvertArrayToSet_withDoubledElements() { 42 | 43 | String[] testArray = {"a", "b", "c", "b", "a"}; 44 | 45 | Set result = Utilities.convertArrayToSet(testArray); 46 | MatcherAssert.assertThat(result, Matchers.containsInAnyOrder("a", "b", "c")); 47 | MatcherAssert.assertThat(result, Matchers.hasSize(3)); 48 | 49 | } 50 | 51 | 52 | @Test 53 | public void test_convertVarargsToArray_happyPath() { 54 | 55 | String[] testArray = {"a", "b", "c"}; 56 | MatcherAssert.assertThat(Arrays.asList(Utilities.convertVarargsToArray("a", "b", "c")), Matchers.containsInAnyOrder("a", "b", "c")); 57 | 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasNoParameterMatcherTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; 4 | import org.hamcrest.MatcherAssert; 5 | import org.hamcrest.Matchers; 6 | import org.junit.Test; 7 | import org.mockito.Mockito; 8 | 9 | import javax.lang.model.element.ExecutableElement; 10 | import javax.lang.model.element.VariableElement; 11 | import javax.lang.model.type.TypeMirror; 12 | import java.util.ArrayList; 13 | import java.util.Collections; 14 | import java.util.List; 15 | 16 | /** 17 | * Unit Test for {@link HasNoParametersMatcher}. 18 | */ 19 | public class HasNoParameterMatcherTest { 20 | 21 | @Test 22 | public void test_check_withNullValue() { 23 | 24 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_PARAMETERS.getMatcher().check(null), Matchers.is(false)); 25 | 26 | } 27 | 28 | @Test 29 | public void test_check_withVoidReturnType() { 30 | 31 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 32 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 33 | Mockito.when(element.getParameters()).thenReturn(Collections.EMPTY_LIST); 34 | 35 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_PARAMETERS.getMatcher().check(element), Matchers.is(true)); 36 | 37 | } 38 | 39 | @Test 40 | public void test_check_withNonVoidReturnType() { 41 | 42 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 43 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 44 | List list = new ArrayList(); 45 | list.add(Mockito.mock(VariableElement.class)); 46 | Mockito.when(element.getParameters()).thenReturn(list); 47 | 48 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_PARAMETERS.getMatcher().check(element), Matchers.is(false)); 49 | 50 | } 51 | 52 | 53 | 54 | } -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasNoThrownTypesMatcherTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; 4 | import org.hamcrest.MatcherAssert; 5 | import org.hamcrest.Matchers; 6 | import org.junit.Test; 7 | import org.mockito.Mockito; 8 | 9 | import javax.lang.model.element.ExecutableElement; 10 | import javax.lang.model.type.TypeMirror; 11 | import java.util.ArrayList; 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | /** 16 | * Unit Test for {@link HasNoParametersMatcher}. 17 | */ 18 | public class HasNoThrownTypesMatcherTest { 19 | 20 | @Test 21 | public void test_check_withNullValue() { 22 | 23 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_THROWN_TYPES.getMatcher().check(null), Matchers.is(false)); 24 | 25 | } 26 | 27 | @Test 28 | public void test_check_withoutThrownTypes() { 29 | 30 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 31 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 32 | Mockito.when(element.getThrownTypes()).thenReturn(Collections.EMPTY_LIST); 33 | 34 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_THROWN_TYPES.getMatcher().check(element), Matchers.is(true)); 35 | 36 | } 37 | 38 | @Test 39 | public void test_check_withNonVoidReturnType() { 40 | 41 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 42 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 43 | List list = new ArrayList(); 44 | list.add(Mockito.mock(TypeMirror.class)); 45 | Mockito.when(element.getThrownTypes()).thenReturn(list); 46 | 47 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_NO_THROWN_TYPES.getMatcher().check(element), Matchers.is(false)); 48 | 49 | } 50 | 51 | 52 | } -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasVoidReturnTypeMatcherTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.matcher.impl; 2 | 3 | import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; 4 | import org.hamcrest.MatcherAssert; 5 | import org.hamcrest.Matchers; 6 | import org.junit.Test; 7 | import org.mockito.Mockito; 8 | 9 | import javax.lang.model.element.ExecutableElement; 10 | import javax.lang.model.type.TypeKind; 11 | import javax.lang.model.type.TypeMirror; 12 | 13 | /** 14 | * Unit Test for {@link HasVoidReturnTypeMatcher}. 15 | */ 16 | public class HasVoidReturnTypeMatcherTest { 17 | 18 | @Test 19 | public void test_check_withNullValue() { 20 | 21 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_VOID_RETURN_TYPE.getMatcher().check(null), Matchers.is(false)); 22 | 23 | } 24 | 25 | @Test 26 | public void test_check_withVoidReturnType() { 27 | 28 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 29 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 30 | Mockito.when(element.getReturnType()).thenReturn(typeMirror); 31 | Mockito.when(typeMirror.getKind()).thenReturn(TypeKind.VOID); 32 | 33 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_VOID_RETURN_TYPE.getMatcher().check(element), Matchers.is(true)); 34 | 35 | } 36 | 37 | @Test 38 | public void test_check_withNonVoidReturnType() { 39 | 40 | ExecutableElement element = Mockito.mock(ExecutableElement.class); 41 | TypeMirror typeMirror = Mockito.mock(TypeMirror.class); 42 | Mockito.when(element.getReturnType()).thenReturn(typeMirror); 43 | Mockito.when(typeMirror.getKind()).thenReturn(TypeKind.ARRAY); 44 | 45 | MatcherAssert.assertThat(AptkCoreMatchers.HAS_VOID_RETURN_TYPE.getMatcher().check(element), Matchers.is(false)); 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tools/src/test/java/io/toolisticon/aptk/tools/wrapper/VariableElementWrapperTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.tools.wrapper; 2 | 3 | import org.hamcrest.MatcherAssert; 4 | import org.hamcrest.Matchers; 5 | import org.junit.Test; 6 | import org.mockito.Mockito; 7 | 8 | import javax.lang.model.element.TypeElement; 9 | import javax.lang.model.element.VariableElement; 10 | 11 | /** 12 | * Unit Test for {@link VariableElementWrapper}. 13 | */ 14 | public class VariableElementWrapperTest { 15 | 16 | @Test 17 | public void test_wrap_and_unwrap() { 18 | VariableElement ve = Mockito.mock(VariableElement.class); 19 | 20 | MatcherAssert.assertThat(ElementWrapper.wrap(ve).unwrap(), Matchers.is(ve)); 21 | } 22 | 23 | @Test 24 | public void test_getConstantValue() { 25 | VariableElement ve = Mockito.spy(VariableElement.class); 26 | VariableElementWrapper.wrap(ve).getConstantValue(); 27 | Mockito.verify(ve, Mockito.times(1)).getConstantValue(); 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tools/src/test/resources/AnnotationClassAttributeTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.annotationprocessor; 2 | 3 | 4 | import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassArrayAttributeAnnotation; 5 | import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassAttributeAnnotation; 6 | import io.toolisticon.aptk.tools.annotationutilstestclasses.DefaultValueAnnotation; 7 | import io.toolisticon.cute.TestAnnotation; 8 | 9 | /** 10 | * Test class for annotation processor tools. 11 | */ 12 | @TestAnnotation 13 | @DefaultValueAnnotation(mandatoryValue = 10L) 14 | public class AnnotationClassAttributeTestClass { 15 | 16 | @ClassAttributeAnnotation() 17 | public void test_classAttribute_empty() { 18 | 19 | }; 20 | 21 | @ClassAttributeAnnotation(String.class) 22 | public void test_classAttribute_atDefaultValue() { 23 | 24 | }; 25 | 26 | @ClassAttributeAnnotation(classAttribute = Long.class) 27 | public void test_classAttribute_atNamedAttribute() { 28 | 29 | }; 30 | 31 | @ClassArrayAttributeAnnotation() 32 | public void test_classArrayAttribute_empty() { 33 | 34 | }; 35 | 36 | @ClassArrayAttributeAnnotation({String.class, Double.class, Float.class}) 37 | public void test_classArrayAttribute_atDefaultValue() { 38 | 39 | }; 40 | 41 | @ClassArrayAttributeAnnotation(classArrayAttribute = {Long.class, Integer.class}) 42 | public void test_classArrayAttribute_atNamedAttribute() { 43 | 44 | }; 45 | 46 | @ClassArrayAttributeAnnotation(classArrayAttribute = {Long.class, Integer.class, AnnotationClassAttributeTestClass.class}) 47 | public void test_classArrayAttribute_atNamedAttribute_withUncompiledClass() { 48 | 49 | }; 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /tools/src/test/resources/AnnotationValueUtilsTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.annotationprocessor; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | import io.toolisticon.aptk.tools.annotationvalueutilstestclasses.AnnotationValueTestAnnotation; 5 | 6 | import javax.tools.StandardLocation; 7 | 8 | /** 9 | * Test class for annotation processor tools. 10 | */ 11 | @TestAnnotation 12 | @AnnotationValueTestAnnotation( 13 | stringValue = "stringValue", 14 | charValue = 'C', 15 | longValue = 1L, 16 | intValue = 1, 17 | booleanValue = true, 18 | //shortValue = 1, 19 | //byteValue = 1, 20 | doubleValue = 1.0, 21 | floatValue = 1.0f, 22 | enumValue = StandardLocation.SOURCE_OUTPUT, 23 | annotationValue = @Deprecated, 24 | classValue = Long.class, 25 | 26 | stringArrayValue = {"1", "2"}, 27 | charArrayValue = {'1', '2'}, 28 | booleanArrayValue = {true, false}, 29 | longArrayValue = {1L, 2L, 3L}, 30 | intArrayValue = {1, 2, 3}, 31 | //shortArrayValue = {1, 2, 3}, 32 | //byteArrayValue = {1, 2, 3}, 33 | doubleArrayValue = {1.0, 2.0, 3.0}, 34 | floatArrayValue = {1.0f, 2.0f, 3.0f}, 35 | enumArrayValue = {StandardLocation.SOURCE_OUTPUT, StandardLocation.CLASS_OUTPUT}, 36 | annotationArrayValue = {@Deprecated}, 37 | classArrayValue = {Long.class, Integer.class} 38 | 39 | 40 | ) 41 | public class AnnotationValueUtilsTestClass { 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tools/src/test/resources/GenericsTestClass.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | import java.util.Comparator; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | @TestAnnotation 10 | public class GenericsTestClass { 11 | 12 | // used for exact match, super (with HashMap) and non matching TypeParameter (HashMap inbetween), pure wildcard 13 | public void isAssignable_testCase1(Map> parameter) { 14 | 15 | } 16 | 17 | // used to test extends clause 18 | public void isAssignable_testCase2(Map> parameter) { 19 | 20 | } 21 | 22 | // used to test extends clause with pure and extends wildcard, generic type() 23 | public void isAssignable_testCase3(Map> parameter) { 24 | 25 | } 26 | 27 | // used to test super clause with pure and super wildcard, generic type() 28 | public void isAssignable_testCase4(Map> parameter) { 29 | 30 | } 31 | 32 | public void isAssignable_testCase5(Map parameter) { 33 | 34 | } 35 | 36 | public void isAssignable_testCase6(Comparator[] comparators1, Comparator[] comparators2, Comparator[] comparators3) { 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /tools/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.beanutils/DefaultNoargConstructorTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | @TestAnnotation 6 | public class DefaultNoargConstructorTest { 7 | 8 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | @TestAnnotation 6 | public class ExplicitNoargConstructorTest { 7 | 8 | public ExplicitNoargConstructorTest() { 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest2.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | @TestAnnotation 6 | public class ExplicitNoargConstructorTest2 { 7 | 8 | public ExplicitNoargConstructorTest2(){ 9 | super(); 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | 7 | @TestAnnotation 8 | public class FieldLevelTestcases { 9 | 10 | public FieldLevelTestcases() { 11 | 12 | } 13 | 14 | private String fieldWithImplementedGetterAndSetters; 15 | 16 | public String getFieldWithImplementedGetterAndSetters() { 17 | return fieldWithImplementedGetterAndSetters; 18 | } 19 | 20 | public void setFieldWithImplementedGetterAndSetters(String fieldWithImplementedGetterAndSetters) { 21 | this.fieldWithImplementedGetterAndSetters = fieldWithImplementedGetterAndSetters; 22 | } 23 | 24 | // -------------------------------------------------------------- 25 | 26 | private String fieldWithoutGetterAndSetter; 27 | 28 | // -------------------------------------------------------------- 29 | 30 | private String fieldWithoutGetter; 31 | 32 | public void setFieldWithoutGetter(String fieldWithoutGetter) { 33 | this.fieldWithoutGetter = fieldWithoutGetter; 34 | } 35 | 36 | // -------------------------------------------------------------- 37 | 38 | private String fieldWithoutSetter; 39 | 40 | public String getFieldWithoutSetter() { 41 | return fieldWithoutSetter; 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | @TestAnnotation 6 | public class TypeHierarchyTestClass { 7 | 8 | 9 | 10 | public static class SuperType { 11 | 12 | private boolean superBooleanField; 13 | private String superStringField; 14 | 15 | public boolean isSuperBooleanField() { 16 | return superBooleanField; 17 | } 18 | 19 | public void setSuperBooleanField(boolean superBooleanField) { 20 | this.superBooleanField = superBooleanField; 21 | } 22 | 23 | public String getSuperStringField() { 24 | return superStringField; 25 | } 26 | 27 | public void setSuperStringField(String superStringField) { 28 | this.superStringField = superStringField; 29 | } 30 | } 31 | 32 | 33 | public static class InheritingType extends SuperType{ 34 | 35 | private boolean booleanField; 36 | 37 | public boolean isBooleanField() { 38 | return booleanField; 39 | } 40 | 41 | public void setBooleanField(boolean booleanField) { 42 | this.booleanField = booleanField; 43 | } 44 | 45 | private String stringField; 46 | 47 | public String getStringField() { 48 | return stringField; 49 | } 50 | 51 | public void setStringField(String stringField) { 52 | this.stringField = stringField; 53 | } 54 | 55 | 56 | private String nonAttributeField; 57 | 58 | public String getNonAttributeField() { 59 | return nonAttributeField; 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | @TestAnnotation 7 | public class GetAttributesCommandTestClass { 8 | 9 | 10 | private static class TestFieldGetterAndSetterMethods { 11 | 12 | private String field1; 13 | 14 | public String getField1() { 15 | return field1; 16 | } 17 | 18 | public void setField1(String field) { 19 | field1 = field; 20 | } 21 | 22 | } 23 | 24 | private static class TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType { 25 | 26 | private String field1; 27 | 28 | public String getField1() { 29 | return field1; 30 | } 31 | 32 | public void setField1(Long field) { 33 | 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk.test; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | 5 | @TestAnnotation 6 | public class GetAttributesCommandWithInheritanceTestClass { 7 | 8 | 9 | private static class TestDataAnnotatedClass { 10 | 11 | private String field1; 12 | private static String field2; 13 | 14 | public String getField1() { 15 | return field1; 16 | } 17 | 18 | public void setField1(String field1) { 19 | this.field1 = field1; 20 | } 21 | } 22 | 23 | private static class TestFieldGetterAndSetterMethods { 24 | 25 | private String field1; 26 | 27 | public String getField1() { 28 | return field1; 29 | } 30 | 31 | public void setField1(String field) { 32 | field1 = field; 33 | } 34 | 35 | } 36 | 37 | private static class TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType { 38 | 39 | private String field1; 40 | 41 | public String getField1() { 42 | return field1; 43 | } 44 | 45 | public void setField1(Long field) { 46 | 47 | } 48 | 49 | } 50 | 51 | 52 | private static class TestInheritedDataAnnotatedClass extends TestDataAnnotatedClass { 53 | 54 | private String field3; 55 | private static String field4; 56 | 57 | public String getField3() { 58 | return field3; 59 | } 60 | 61 | public void setField3(String field3) { 62 | this.field3 = field3; 63 | } 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoArgsConstructorAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | import lombok.NoArgsConstructor; 5 | 6 | @TestAnnotation 7 | @NoArgsConstructor 8 | public class LombokNoArgsConstructorAnnotation { 9 | 10 | public LombokNoArgsConstructorAnnotation(String test) { 11 | 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoConstructorWithAllArgsConstructorAnnotation.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.aptk; 2 | 3 | import io.toolisticon.cute.TestAnnotation; 4 | import lombok.AllArgsConstructor; 5 | 6 | @TestAnnotation 7 | @AllArgsConstructor 8 | public class LombokNoConstructorWithAllArgsConstructorAnnotation { 9 | 10 | 11 | } -------------------------------------------------------------------------------- /tools/src/test/resources/testcases/generators/FilerUtilsTestClass.java: -------------------------------------------------------------------------------- 1 | package io.toolisticon.annotationprocessor; 2 | 3 | import io.toolisticon.aptk.tools.generators.FileObjectUtilsTestAnnotation; 4 | import io.toolisticon.cute.TestAnnotation; 5 | 6 | /** 7 | * Test class for annotation processor tools. 8 | */ 9 | @TestAnnotation 10 | public class FilerUtilsTestClass { 11 | 12 | 13 | @FileObjectUtilsTestAnnotation 14 | public String testMethod1() { 15 | return null; 16 | } 17 | 18 | @FileObjectUtilsTestAnnotation 19 | public String testMethod2() { 20 | return null; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /tools/src/test/resources/testcases/generators/expectedResult.txt: -------------------------------------------------------------------------------- 1 | testMethod1 2 | testMethod2 3 | -------------------------------------------------------------------------------- /tools/src/test/resources/testcases/generators/testTemplate.tpl: -------------------------------------------------------------------------------- 1 | AB${value}EF --------------------------------------------------------------------------------