Class JavaPoetUtils


  • public class JavaPoetUtils
    extends java.lang.Object
    Collection of static utils that rely on JavaPoet to function.
    • Constructor Detail

      • JavaPoetUtils

        public JavaPoetUtils()
    • Method Detail

      • buildStringReturnMethod

        public static MethodSpec buildStringReturnMethod​(java.lang.String name,
                                                         java.lang.String returnString)
        Builds a MethodSpec for a public method whose body simply returns a String.
        Parameters:
        name - the name of the method
        returnString - the String to return
        Returns:
        the built MethodSpec
      • appendMemberFinderDefinition

        public static void appendMemberFinderDefinition​(javax.lang.model.element.VariableElement var,
                                                        javax.lang.model.element.ExecutableElement stub,
                                                        Target t,
                                                        MethodSpec.Builder con,
                                                        ProcessorOptions options)
        Appends to a given MethodSpec.Builder definitions for a proxy.
        Parameters:
        var - the VariableElement representing the proxy
        stub - the stub ExecutableElement if present or relevant, null otherwise
        t - the Target relevant to this finder if present or relevant, null otherwise
        con - the MethodSpec.Builder to append to
        options - the ProcessorOptions to be used
        Since:
        0.5.0
      • generateDummies

        public static java.util.HashSet<MethodSpec> generateDummies​(javax.lang.model.element.TypeElement clazz)
        Generates a HashSet of dummy overrides for every abstract method in a given class, represented as a TypeElement.
        Parameters:
        clazz - the given class
        Returns:
        a HashSet containing the generated MethodSpecs
        Since:
        0.5.0
      • generateInjector

        public static MethodSpec generateInjector​(InjectorInfo inj,
                                                  javax.annotation.processing.ProcessingEnvironment env)
        Generates the wrapper around a certain injector.
        Parameters:
        inj - the InjectorInfo carrying the information about the target injector
        env - the ProcessingEnvironment to perform the operation in
        Returns:
        the generated MethodSpec for the injector
        Since:
        0.6.0