Search in sources :

Example 31 with ParameterizedTypeName

use of com.squareup.javapoet.ParameterizedTypeName in project butterknife by JakeWharton.

the class BindingSet method newBuilder.

static Builder newBuilder(TypeElement enclosingElement) {
    TypeMirror typeMirror = enclosingElement.asType();
    boolean isView = isSubtypeOfType(typeMirror, VIEW_TYPE);
    boolean isActivity = isSubtypeOfType(typeMirror, ACTIVITY_TYPE);
    boolean isDialog = isSubtypeOfType(typeMirror, DIALOG_TYPE);
    TypeName targetType = TypeName.get(typeMirror);
    if (targetType instanceof ParameterizedTypeName) {
        targetType = ((ParameterizedTypeName) targetType).rawType;
    }
    String packageName = getPackage(enclosingElement).getQualifiedName().toString();
    String className = enclosingElement.getQualifiedName().toString().substring(packageName.length() + 1).replace('.', '$');
    ClassName bindingClassName = ClassName.get(packageName, className + "_ViewBinding");
    boolean isFinal = enclosingElement.getModifiers().contains(Modifier.FINAL);
    return new Builder(targetType, bindingClassName, isFinal, isView, isActivity, isDialog);
}
Also used : WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeName(com.squareup.javapoet.TypeName) TypeMirror(javax.lang.model.type.TypeMirror) ClassName(com.squareup.javapoet.ClassName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName)

Aggregations

ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)31 TypeName (com.squareup.javapoet.TypeName)23 ClassName (com.squareup.javapoet.ClassName)21 TypeSpec (com.squareup.javapoet.TypeSpec)14 MethodSpec (com.squareup.javapoet.MethodSpec)13 TypeElement (javax.lang.model.element.TypeElement)10 WildcardTypeName (com.squareup.javapoet.WildcardTypeName)9 TypeMirror (javax.lang.model.type.TypeMirror)8 Map (java.util.Map)6 ArrayTypeName (com.squareup.javapoet.ArrayTypeName)5 FieldSpec (com.squareup.javapoet.FieldSpec)5 ParameterSpec (com.squareup.javapoet.ParameterSpec)5 TypeVariableName (com.squareup.javapoet.TypeVariableName)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 Builder (com.squareup.javapoet.TypeSpec.Builder)4 Attribute (io.requery.meta.Attribute)4 AnnotationSpec (com.squareup.javapoet.AnnotationSpec)3 CodeBlock (com.squareup.javapoet.CodeBlock)3