本文整理匯總了Java中com.squareup.javapoet.ClassName.simpleNames方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassName.simpleNames方法的具體用法?Java ClassName.simpleNames怎麽用?Java ClassName.simpleNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.squareup.javapoet.ClassName
的用法示例。
在下文中一共展示了ClassName.simpleNames方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEnhancedClassName
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
@Nonnull
ClassName getEnhancedClassName()
{
final ClassName className = ClassName.get( getElement() );
final ArrayList<String> names = new ArrayList<>( className.simpleNames() );
final String cname = getElement().getSimpleName() + "_";
if ( names.size() > 1 )
{
names.remove( names.size() - 1 );
names.add( cname );
return ClassName.get( getPackageName(),
names.get( 0 ),
names.subList( 1, names.size() ).toArray( new String[ 0 ] ) );
}
else
{
return ClassName.get( getPackageName(), cname );
}
}
示例2: toTypeMirror
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private TypeMirror toTypeMirror(Object name) {
if (name instanceof TypeMirror) {
return (TypeMirror)name;
} else if (name instanceof Class) {
return this.elements.getTypeElement(((Class)name).getCanonicalName()).asType();
} else if (name instanceof String) {
return this.elements.getTypeElement((String) name).asType();
} else if (name instanceof ClassName) {
ClassName clazz = (ClassName)name;
StringBuilder classNameBuilder = new StringBuilder();
classNameBuilder.append(clazz.packageName());
for (String elt : clazz.simpleNames()) {
classNameBuilder.append(".");
classNameBuilder.append(elt);
}
return this.elements.getTypeElement(classNameBuilder.toString()).asType();
} else if (name instanceof ParameterizedTypeName) {
return this.toTypeMirror(((ParameterizedTypeName)name).rawType);
} else if (name instanceof TypeName) {
return this.elements.getTypeElement(((TypeName)name).withoutAnnotations().toString()).asType();
} else {
throw new IllegalArgumentException(String.format("Invalid type name: %s", name));
}
}
示例3: getInjectedFQCN
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
public static String getInjectedFQCN(ClassName className) {
StringBuilder name = new StringBuilder();
for (String part : className.simpleNames()) {
if (name.length() > 0) {
name.append("$");
}
name.append(part);
}
return className.packageName() + "." + name.toString() + Constants.MAPPER_CLASS_SUFFIX;
}