/** Return the binary name of a class. */ public String reflectionName() { return enclosingClassName != null ? (enclosingClassName.reflectionName() + '$' + simpleName) : (packageName.isEmpty() ? simpleName : packageName + '.' + simpleName); }
static Class<?> getClass(ClassName name) { try { return Class.forName(name.reflectionName()); } catch (ClassNotFoundException | NoClassDefFoundError e) { return null; } }
static TypeElement getElementByName(ClassName name, Elements elements, Types types) { String canonicalName = name.reflectionName().replace("$", "."); return (TypeElement) getElementByName(canonicalName, elements, types); }
static boolean isType(TypeMirror type, ClassName className) { return isType(type, className.reflectionName()); }
@Override public Set<String> getSupportedAnnotationTypes() { Set<String> types = new LinkedHashSet<>(); types.add(EpoxyModelClass.class.getCanonicalName()); types.add(EpoxyAttribute.class.getCanonicalName()); types.add(PackageEpoxyConfig.class.getCanonicalName()); types.add(AutoModel.class.getCanonicalName()); types.add(EpoxyDataBindingLayouts.class.getCanonicalName()); types.add(EpoxyDataBindingPattern.class.getCanonicalName()); types.add(ModelView.class.getCanonicalName()); types.add(PackageModelViewConfig.class.getCanonicalName()); types.add(TextProp.class.getCanonicalName()); types.add(CallbackProp.class.getCanonicalName()); types.add(ClassNames.LITHO_ANNOTATION_LAYOUT_SPEC.reflectionName()); return types; }
String rLayoutClassString = rClassName.reflectionName(); if (!rLayoutClassString.endsWith(".R") && !rLayoutClassString.endsWith(".R2")) {
} else { ClassName rawType = ClassName.bestGuess(eraseGenericIfNecessary(superType).toString() + STATE_SAVER_SUFFIX); if (!rawType.toString().equals(rawType.reflectionName())) { rawType = ClassName.bestGuess(rawType.reflectionName());
public boolean isReturnString() { if (!(type instanceof ClassName)) { return false; } ClassName className = (ClassName) type; return className.reflectionName().equals("String") || className .reflectionName() .equals(String.class.getCanonicalName()); }
private Object defaultRequestPath(Rpc rpc, ClassName className) { ArrayList<String> params = Lists.newArrayList(RaptorConstants.RAPTOR, className.reflectionName(), rpc.name()); return RaptorConstants.PATH_SEPARATOR + StringUtils.join(params, RaptorConstants.PATH_SEPARATOR); }
@Override public Optional<TypeElement> findTypeElement(ClassName cn) { return Optional.ofNullable(elements().getTypeElement(cn.reflectionName().replace("$", "."))); }
private boolean extendsController(Element element) { TypeMirror target = elementUtils.getTypeElement(CONDUCTOR_CONTROLLER.reflectionName()).asType(); TypeMirror mirror = element.asType(); while (mirror.getKind() != TypeKind.NONE) { if (typeUtils.isSameType(target, mirror)) { return true; } mirror = ((TypeElement) typeUtils.asElement(mirror)).getSuperclass(); } return false; }
@Override public Optional<TypeElement> findTypeElement(ClassName cn) { return Optional.ofNullable(elements().getTypeElement(cn.reflectionName().replace("$", "."))); }
public static void toJavaFile(Filer filer, Builder classBuilder, ClassName className, TypeElement... originatingElement) { try { JavaFile javaFile = JavaFile.builder(className.packageName(), classBuilder.build()).build(); JavaFileObject javaFileObject = filer.createSourceFile(className.reflectionName(), originatingElement); Writer writer = javaFileObject.openWriter(); javaFile.writeTo(writer); writer.close(); } catch (IOException e) { e.printStackTrace(); } }
public static ClassName nameWithSuffix(ClassName className, String suffix) { return nameWithSuffix(className.reflectionName(), suffix); }
private boolean isListProperty(final PropertyGenModel propertyGenModel){ final boolean isParmetrizedList = (propertyGenModel.getType() instanceof ParameterizedTypeName) && ((ParameterizedTypeName)propertyGenModel.getType()).rawType.reflectionName().equals(List.class.getTypeName()); final boolean isNonParmetrizedList = (propertyGenModel.getType() instanceof ClassName) && ((ClassName)propertyGenModel.getType()).reflectionName().equals(List.class.getTypeName()); return isNonParmetrizedList || isParmetrizedList; }
private boolean isSetProperty(final PropertyGenModel propertyGenModel){ final boolean isParmetrizedSet = (propertyGenModel.getType() instanceof ParameterizedTypeName) && ((ParameterizedTypeName)propertyGenModel.getType()).rawType.reflectionName().equals(Set.class.getTypeName()); final boolean isNonParmetrizedSet = (propertyGenModel.getType() instanceof ClassName) && ((ClassName)propertyGenModel.getType()).reflectionName().equals(Set.class.getTypeName()); return isNonParmetrizedSet || isParmetrizedSet; }
private boolean isListProperty(final PropertyGenModel propertyGenModel){ final boolean isParmetrizedList = (propertyGenModel.getType() instanceof ParameterizedTypeName) && ((ParameterizedTypeName)propertyGenModel.getType()).rawType.reflectionName().equals(List.class.getTypeName()); final boolean isNonParmetrizedList = (propertyGenModel.getType() instanceof ClassName) && ((ClassName)propertyGenModel.getType()).reflectionName().equals(List.class.getTypeName()); return isNonParmetrizedList || isParmetrizedList; }
private boolean isSetProperty(final PropertyGenModel propertyGenModel){ final boolean isParmetrizedSet = (propertyGenModel.getType() instanceof ParameterizedTypeName) && ((ParameterizedTypeName)propertyGenModel.getType()).rawType.reflectionName().equals(Set.class.getTypeName()); final boolean isNonParmetrizedSet = (propertyGenModel.getType() instanceof ClassName) && ((ClassName)propertyGenModel.getType()).reflectionName().equals(Set.class.getTypeName()); return isNonParmetrizedSet || isParmetrizedSet; }
private Optional<TemplateFileResource> getTemplateContent(ClassName componentTypeName, TypeElement componentTypeElement) { String path = slashify(componentTypeName.reflectionName()) + ".html"; Optional<TemplateFileResource> result = getTemplateContentAtLocation(path, StandardLocation.CLASS_OUTPUT); if (result.isPresent()) { return result; } result = getTemplateContentAtLocation(path, StandardLocation.CLASS_PATH); if (result.isPresent()) { return result; } messager.printMessage(Kind.ERROR, "Couldn't find template for component: " + componentTypeName.simpleName() + ". Make sure you included src/main/java in your Resources. Check our setup guide for help.", componentTypeElement); return Optional.empty(); }
"$T.of($S)", ClassName.get("dagger.android.internal", "AndroidInjectionKeys"), ClassName.get(unwrappedType).reflectionName());