All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.RGAnnotationDatabaseImpl.vm Maven / Gradle / Ivy

The newest version!
#if( $packageName )
package $packageName;
#end

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.google.inject.AnnotationDatabase;
#if( $isUsingFragmentUtil )
import roboguice.fragment.FragmentUtil;
#end

public class AnnotationDatabaseImpl extends AnnotationDatabase {

    public void fillAnnotationClassesAndFieldsNames(HashMap> mapAnnotationToMapClassWithInjectionNameToFieldSet) {
#if( !$mapAnnotationToMapClassWithInjectionNameToFieldSet.isEmpty() )

        String annotationClassName = null;
        Map mapClassWithInjectionNameToFieldSet = null;
        String[] fieldNameSet = null;

#foreach( $annotationName in $mapAnnotationToMapClassWithInjectionNameToFieldSet.keySet() )

        annotationClassName = "$annotationName";
        mapClassWithInjectionNameToFieldSet = mapAnnotationToMapClassWithInjectionNameToFieldSet.get(annotationClassName);
        if( mapClassWithInjectionNameToFieldSet == null ) {
            mapClassWithInjectionNameToFieldSet = new HashMap();
            mapAnnotationToMapClassWithInjectionNameToFieldSet.put(annotationClassName, mapClassWithInjectionNameToFieldSet);
        }

#foreach( $className in $mapAnnotationToMapClassWithInjectionNameToFieldSet.get($annotationName).keySet() )
        fieldNameSet = new String[] {
#foreach( $fieldName in $mapAnnotationToMapClassWithInjectionNameToFieldSet.get($annotationName).get($className) )
        "$fieldName",
#end
        };
        mapClassWithInjectionNameToFieldSet.put("$className", fieldNameSet);

#end
#end
#end
    }

    public void fillAnnotationClassesAndMethods(HashMap> mapAnnotationToMapClassWithInjectionNameToMethodsSet) {
#if( !$mapAnnotationToMapClassWithInjectionNameToMethodSet.isEmpty() )

        String annotationClassName = null;
        Map mapClassWithInjectionNameToMethodSet = null;
        String[] methodSet = null;

#foreach( $annotationName in $mapAnnotationToMapClassWithInjectionNameToMethodSet.keySet() )

        annotationClassName = "$annotationName";
        mapClassWithInjectionNameToMethodSet = mapAnnotationToMapClassWithInjectionNameToMethodsSet.get(annotationClassName);
        if( mapClassWithInjectionNameToMethodSet == null ) {
            mapClassWithInjectionNameToMethodSet = new HashMap();
            mapAnnotationToMapClassWithInjectionNameToMethodsSet.put(annotationClassName, mapClassWithInjectionNameToMethodSet);
        }

#foreach( $className in $mapAnnotationToMapClassWithInjectionNameToMethodSet.get($annotationName).keySet() )
        methodSet = new String[] {
#foreach( $method in $mapAnnotationToMapClassWithInjectionNameToMethodSet.get($annotationName).get($className) )
        "$method",
#end
        };
        mapClassWithInjectionNameToMethodSet.put("$className", methodSet);

#end
#end
#end
    }

    public void fillAnnotationClassesAndConstructors(HashMap> mapAnnotationToMapClassWithInjectionNameToConstructorsSet) {
#if( !$mapAnnotationToMapClassWithInjectionNameToConstructorSet.isEmpty() )

        String annotationClassName = null;
        Map mapClassWithInjectionNameToConstructorSet = null;
        String[] constructorSet = null;

#foreach( $annotationName in $mapAnnotationToMapClassWithInjectionNameToConstructorSet.keySet() )

        annotationClassName = "$annotationName";
        mapClassWithInjectionNameToConstructorSet = mapAnnotationToMapClassWithInjectionNameToConstructorsSet.get(annotationClassName);
        if( mapClassWithInjectionNameToConstructorSet == null ) {
            mapClassWithInjectionNameToConstructorSet = new HashMap();
            mapAnnotationToMapClassWithInjectionNameToConstructorsSet.put(annotationClassName, mapClassWithInjectionNameToConstructorSet);
        }

#foreach( $className in $mapAnnotationToMapClassWithInjectionNameToConstructorSet.get($annotationName).keySet() )
        constructorSet = new String[] {
#foreach( $constructor in $mapAnnotationToMapClassWithInjectionNameToConstructorSet.get($annotationName).get($className) )
        "$constructor",
#end
        };
        mapClassWithInjectionNameToConstructorSet.put("$className", constructorSet);

#end
#end
#end
    }

    public void fillClassesContainingInjectionPointSet(HashSet classesContainingInjectionPointsSet) {
#foreach( $className in $classesContainingInjectionPointsSet )
        classesContainingInjectionPointsSet.add("$className");
#end
    }


    public void fillBindableClasses(HashSet injectedClasses) {
#foreach( $className in $injectedClasses )
        injectedClasses.add("$className");
#end

#if( $isUsingFragmentUtil )
        if(FragmentUtil.hasNative) {
            injectedClasses.add("android.app.FragmentManager");
        }

        if(FragmentUtil.hasSupport) {
            injectedClasses.add("android.support.v4.app.FragmentManager");
        }
#end
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy