Search in sources :

Example 1 with MemberAccess

use of com.github.sviperll.adt4j.MemberAccess in project adt4j by sviperll.

the class ValueClassConfiguration method createInstance.

public static GenerationResult<ValueClassConfiguration> createInstance(VisitorDefinition visitorDefinition, JAnnotationUse annotation, JDefinedClass valueClass) {
    GenerationProcess generation = new GenerationProcess();
    String acceptMethodName = annotation.getParam("acceptMethodName", String.class);
    MemberAccess acceptMethodAccess = annotation.getParam("acceptMethodAccess", MemberAccess.class);
    boolean isPublic = annotation.getParam("isPublic", Boolean.class);
    Caching hashCodeCaching = annotation.getParam("hashCodeCaching", Caching.class);
    int hashCodeBase = annotation.getParam("hashCodeBase", Integer.class);
    boolean isComparable = annotation.getParam("isComparable", Boolean.class);
    float floatEpsilon = annotation.getParam("floatEpsilon", Float.class);
    double doubleEpsilon = annotation.getParam("doubleEpsilon", Double.class);
    FloatCustomization floatCustomization = new FloatCustomization(floatEpsilon, doubleEpsilon);
    Serialization serialization = serialization(annotation);
    ClassCustomization classCustomization = generation.processGenerationResult(classCustomization(annotation, visitorDefinition, valueClass));
    AbstractJClass[] interfaces = annotation.getParam("implementsInterfaces", AbstractJClass[].class);
    AcceptMethodCustomization acceptMethodCustomization = new AcceptMethodCustomization(acceptMethodName, acceptMethodAccess);
    InterfacesCustomization interfaceCustomization = new InterfacesCustomization(isComparable, serialization, interfaces);
    APICustomization apiCustomization = new APICustomization(isPublic, acceptMethodCustomization, interfaceCustomization);
    ImplementationCustomization implementationCustomization = new ImplementationCustomization(hashCodeCaching, hashCodeBase, floatCustomization);
    Customization customiztion = new Customization(classCustomization, apiCustomization, implementationCustomization);
    return generation.createGenerationResult(new ValueClassConfiguration(visitorDefinition, customiztion));
}
Also used : AbstractJClass(com.helger.jcodemodel.AbstractJClass) MemberAccess(com.github.sviperll.adt4j.MemberAccess) Caching(com.github.sviperll.adt4j.Caching) GenerationProcess(com.github.sviperll.adt4j.model.util.GenerationProcess)

Example 2 with MemberAccess

use of com.github.sviperll.adt4j.MemberAccess in project adt4j by sviperll.

the class FieldReader method readUpdater.

GenerationResult<Void> readUpdater(MethodUsage interfaceMethod, VariableDeclaration param, AbstractJType paramType, boolean isVarArg) {
    GenerationProcess generation = new GenerationProcess();
    for (JAnnotationUse annotationUsage : param.annotations()) {
        AbstractJClass annotationClass = annotationUsage.getAnnotationClass();
        if (!annotationClass.isError()) {
            String annotationClassName = annotationClass.fullName();
            if (annotationClassName != null && annotationClassName.equals(Updater.class.getName())) {
                String updaterName = annotationUsage.getParam("name", String.class);
                if (updaterName == null || updaterName.equals(":auto"))
                    updaterName = "with" + Source.capitalize(param.name());
                MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
                boolean isNullable = Source.isNullable(param);
                FieldFlags flags = new FieldFlags(isNullable, isVarArg, accessLevel);
                FieldConfiguration configuration = new FieldConfiguration(updaterName, paramType, flags);
                generation.processGenerationResult(read(interfaceMethod, param, configuration));
            }
        }
    }
    return generation.<Void>createGenerationResult(null);
}
Also used : MemberAccess(com.github.sviperll.adt4j.MemberAccess) JAnnotationUse(com.helger.jcodemodel.JAnnotationUse) AbstractJClass(com.helger.jcodemodel.AbstractJClass) GenerationProcess(com.github.sviperll.adt4j.model.util.GenerationProcess)

Example 3 with MemberAccess

use of com.github.sviperll.adt4j.MemberAccess in project adt4j by sviperll.

the class FieldReader method readGetter.

GenerationResult<Void> readGetter(MethodUsage interfaceMethod, VariableDeclaration param, AbstractJType paramType, boolean isVarArg) {
    GenerationProcess generation = new GenerationProcess();
    for (JAnnotationUse annotationUsage : param.annotations()) {
        AbstractJClass annotationClass = annotationUsage.getAnnotationClass();
        if (!annotationClass.isError()) {
            String annotationClassName = annotationClass.fullName();
            if (annotationClassName != null && annotationClassName.equals(Getter.class.getName())) {
                String getterName = annotationUsage.getParam("name", String.class);
                if (getterName == null || getterName.equals(":auto"))
                    getterName = param.name();
                MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
                boolean isNullable = Source.isNullable(param);
                FieldFlags flags = new FieldFlags(isNullable, isVarArg, accessLevel);
                FieldConfiguration configuration = new FieldConfiguration(getterName, paramType, flags);
                generation.processGenerationResult(read(interfaceMethod, param, configuration));
            }
        }
    }
    return generation.<Void>createGenerationResult(null);
}
Also used : MemberAccess(com.github.sviperll.adt4j.MemberAccess) JAnnotationUse(com.helger.jcodemodel.JAnnotationUse) AbstractJClass(com.helger.jcodemodel.AbstractJClass) GenerationProcess(com.github.sviperll.adt4j.model.util.GenerationProcess)

Example 4 with MemberAccess

use of com.github.sviperll.adt4j.MemberAccess in project adt4j by sviperll.

the class PredicatesReader method read.

GenerationResult<Void> read(JMethod interfaceMethod, JAnnotationUse annotationUsage) {
    GenerationProcess generation = new GenerationProcess();
    String annotationClassName = annotationUsage.getAnnotationClass().fullName();
    if (annotationClassName != null) {
        if (annotationClassName.equals(GeneratePredicate.class.getName())) {
            String predicateName = annotationUsage.getParam("name", String.class);
            MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
            generation.processGenerationResult(read(interfaceMethod, predicateName, accessLevel));
        } else if (annotationClassName.equals(GeneratePredicates.class.getName())) {
            JAnnotationUse[] annotations = annotationUsage.getParam("value", JAnnotationUse[].class);
            if (annotations != null) {
                for (JAnnotationUse annotation : annotations) {
                    generation.processGenerationResult(read(interfaceMethod, annotation));
                }
            }
        }
    }
    return generation.createGenerationResult(null);
}
Also used : MemberAccess(com.github.sviperll.adt4j.MemberAccess) JAnnotationUse(com.helger.jcodemodel.JAnnotationUse) GenerationProcess(com.github.sviperll.adt4j.model.util.GenerationProcess) GeneratePredicate(com.github.sviperll.adt4j.GeneratePredicate)

Aggregations

MemberAccess (com.github.sviperll.adt4j.MemberAccess)4 GenerationProcess (com.github.sviperll.adt4j.model.util.GenerationProcess)4 AbstractJClass (com.helger.jcodemodel.AbstractJClass)3 JAnnotationUse (com.helger.jcodemodel.JAnnotationUse)3 Caching (com.github.sviperll.adt4j.Caching)1 GeneratePredicate (com.github.sviperll.adt4j.GeneratePredicate)1