Class IteratingWrapperClassBuilder


  • @GwtIncompatible("java.lang.reflect.*")
    public class IteratingWrapperClassBuilder
    extends java.lang.Object
    A builder of classes to wrap a provided SubjectFactory's concrete Subject subclass. The generated class will be a direct subclass of the concrete Subject subclass, but each public, protected, or friendly method not declared by Object will be wrapped such that invocations on it will be invoked on a new Subject instance populated with an element in the provided collection. This allows for a type-safe, IDE-discoverable Subject in a for-each style.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void appendMethodWrapper​(java.lang.StringBuilder code, java.lang.Class<?> subjectType, java.lang.Class<?> targetType, java.lang.reflect.Method method)  
      java.lang.String build()  
      private static java.lang.StringBuilder methodParameterList​(int length)  
      private static java.lang.StringBuilder methodSignature​(java.lang.Class<?>[] parameters, java.lang.annotation.Annotation[][] annotations)
      Builds a string for the parameters within a method signature.
      private static java.lang.String stringVisibility​(int modifiers)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CLASS_TEMPLATE

        private static final java.lang.String CLASS_TEMPLATE

        A string intended for use in String.format() representing the text of the code of the wrapper class.

        Format parameters include:

        1. package name
        2. simple name of a concrete subtype of Subject
        3. the fully qualified name of the target type
        4. the text of the code of the wrapped methods

        See Also:
        Constant Field Values
      • WRAPPER_METHOD_TEMPLATE

        private static final java.lang.String WRAPPER_METHOD_TEMPLATE

        A string intended for use in String.format() representing the text of the code of all wrapped methods.

        Format parameters include:

        1. visibility
        2. fully qualified name of the return type
        3. method name
        4. method's parameter list
        5. the target type of the Subject
        6. concrete subtype of Subject to be wrapped
        7. parameter list

        See Also:
        Constant Field Values
      • ITERATING_WRAPPER

        private static final java.lang.String ITERATING_WRAPPER
        See Also:
        Constant Field Values
      • className

        public final java.lang.String className
    • Constructor Detail

      • IteratingWrapperClassBuilder

        public IteratingWrapperClassBuilder​(SubjectFactory<?,​?> subjectFactory)
    • Method Detail

      • build

        public java.lang.String build()
      • appendMethodWrapper

        private void appendMethodWrapper​(java.lang.StringBuilder code,
                                         java.lang.Class<?> subjectType,
                                         java.lang.Class<?> targetType,
                                         java.lang.reflect.Method method)
      • methodParameterList

        private static java.lang.StringBuilder methodParameterList​(int length)
      • methodSignature

        private static java.lang.StringBuilder methodSignature​(java.lang.Class<?>[] parameters,
                                                               java.lang.annotation.Annotation[][] annotations)
        Builds a string for the parameters within a method signature.
      • stringVisibility

        private static java.lang.String stringVisibility​(int modifiers)