Package com.google.common.truth.codegen
Class IteratingWrapperClassBuilder
- java.lang.Object
-
- com.google.common.truth.codegen.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.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CLASS_TEMPLATE
A string intended for use in String.format() representing the text of the code of the wrapper class.java.lang.String
className
private static java.lang.String
ITERATING_WRAPPER
private SubjectFactory<?,?>
subjectFactory
private static int
TARGET_TYPE_PARAMETER
private static java.lang.String
WRAPPER_METHOD_TEMPLATE
A string intended for use in String.format() representing the text of the code of all wrapped methods.
-
Constructor Summary
Constructors Constructor Description IteratingWrapperClassBuilder(SubjectFactory<?,?> subjectFactory)
-
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)
-
-
-
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:
- package name
- simple name of a concrete subtype of Subject
- the fully qualified name of the target type
- 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:
- visibility
- fully qualified name of the return type
- method name
- method's parameter list
- the target type of the Subject
- concrete subtype of Subject to be wrapped
- parameter list
- See Also:
- Constant Field Values
-
TARGET_TYPE_PARAMETER
private static final int TARGET_TYPE_PARAMETER
- See Also:
- Constant Field Values
-
ITERATING_WRAPPER
private static final java.lang.String ITERATING_WRAPPER
- See Also:
- Constant Field Values
-
subjectFactory
private final SubjectFactory<?,?> subjectFactory
-
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)
-
-