com.squareup.javapoet.ClassName.peerClass()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中com.squareup.javapoet.ClassName.peerClass()方法的一些代码示例,展示了ClassName.peerClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassName.peerClass()方法的具体详情如下:
包路径:com.squareup.javapoet.ClassName
类名称:ClassName
方法名:peerClass

ClassName.peerClass介绍

[英]Returns a class that shares the same enclosing package or class. If this class is enclosed by another class, this is equivalent to enclosingClassName().nestedClass(name). Otherwise it is equivalent to get(packageName(), name).
[中]返回共享同一封闭包或类的类。如果该类由另一个类封闭,则相当于封闭ClassName()。nestedClass(名称)。否则它相当于get(packageName(),name)。

代码示例

代码示例来源:origin: square/wire

/**
 * Returns the Java type of the abstract adapter class generated for a corresponding {@code
 * protoType}. Returns null if {@code protoType} is not using a custom proto adapter.
 */
public @Nullable ClassName abstractAdapterName(ProtoType protoType) {
 TypeName profileJavaName = profile.getTarget(protoType);
 if (profileJavaName == null) return null;
 ClassName javaName = nameToJavaName.get(protoType);
 Type type = schema.getType(protoType);
 return type instanceof EnumType
   ? javaName.peerClass(javaName.simpleName() + "Adapter")
   : javaName.peerClass("Abstract" + javaName.simpleName() + "Adapter");
}

代码示例来源:origin: br.com.objectos.orm/compiler

private ParameterizedTypeName rowTypeName(List<? extends OrmProperty> propertyList) {
 ClassName rowClassName = ClassName.get(Row.class).peerClass("Row" + propertyList.size());
 ClassName[] columnClassNameArray = propertyList.stream()
   .sorted()
   .flatMap(OrmProperty::columnClassNameStream)
   .toArray(ClassName[]::new);
 return ParameterizedTypeName.get(rowClassName, columnClassNameArray);
}

代码示例来源:origin: br.com.objectos.orm/compiler

private ParameterizedTypeName rowTypeName(List<? extends OrmProperty> propertyList) {
 ClassName rowClassName = ClassName.get(Row.class).peerClass("Row" + propertyList.size());
 ClassName[] columnClassNameArray = propertyList.stream()
   .sorted()
   .flatMap(OrmProperty::columnClassNameStream)
   .toArray(ClassName[]::new);
 return ParameterizedTypeName.get(rowClassName, columnClassNameArray);
}

代码示例来源:origin: br.com.objectos/pojo-plugin

public ClassName superClassSuffix(String suffix) {
 String simpleName = superClass.simpleName();
 return superClass.peerClass(simpleName + suffix);
}

代码示例来源:origin: br.com.objectos.pojo/plugin

public ClassName superClassSuffix(String suffix) {
 String simpleName = superClass.simpleName();
 return superClass.peerClass(simpleName + suffix);
}

代码示例来源:origin: br.com.objectos.way/pojo-plugin

public ClassName superClassSuffix(String suffix) {
 String simpleName = superClass.simpleName();
 return superClass.peerClass(simpleName + suffix);
}

代码示例来源:origin: br.com.objectos/masche-info

public ClassName schemaClassName(String simpleName) {
 return className().peerClass(simpleName);
}

代码示例来源:origin: br.com.objectos/sql-meta

public ClassName schemaClassName(String simpleName) {
 return className().peerClass(simpleName);
}

代码示例来源:origin: br.com.objectos/sql-meta

public ClassName className() {
 return migrationVersion.className().peerClass(simpleName);
}

代码示例来源:origin: br.com.objectos/masche-info

public ClassName className() {
 return migrationVersion.className().peerClass(simpleName);
}

代码示例来源:origin: com.google.dagger/dagger-compiler

/**
 * Returns the name of the generated class that contains the static {@code create} methods for an
 * annotation type.
 */
static ClassName getAnnotationCreatorClassName(TypeElement annotationType) {
 ClassName annotationTypeName = ClassName.get(annotationType);
 return annotationTypeName
   .topLevelClassName()
   .peerClass(classFileName(annotationTypeName) + "Creator");
}

代码示例来源:origin: br.com.objectos.html/boot

public static ProtoTypeNaming of(TypeInfo typeInfo) {
 String elementSimpleName = classSimpleName(typeInfo);
 ClassName enclosingClassName = typeInfo.enclosingTypeInfo()
   .get()
   .className();
 return new ProtoTypeNaming(
   elementSimpleName,
   enclosingClassName.peerClass(elementSimpleName),
   enclosingClassName.peerClass(elementSimpleName + "Proto"));
}

代码示例来源:origin: ppdai-incubator/raptor

/**
 * Returns the Java type of the abstract adapter class generated for a corresponding {@code
 * protoType}. Returns null if {@code protoType} is not using a custom proto adapter.
 */
public ClassName abstractAdapterName(ProtoType protoType) {
  TypeName profileJavaName = profile.getTarget(protoType);
  if (profileJavaName == null) {
    return null;
  }
  ClassName javaName = nameToJavaName.get(protoType);
  return javaName.peerClass("Abstract" + javaName.simpleName() + "Adapter");
}

代码示例来源:origin: com.google.dagger/dagger-compiler

private static ClassName siblingClassName(TypeElement typeElement, String suffix) {
 ClassName className = ClassName.get(typeElement);
 return className.topLevelClassName().peerClass(classFileName(className) + suffix);
}

代码示例来源:origin: br.com.objectos.html/boot

private ClassName superclassTypeNameRaw() {
 TypeInfo baseTypeInfo = typeInfo.interfaceTypeInfoAnnotatedWith(BaseType.class).get();
 return baseTypeInfo.annotationInfo(BaseType.class)
   .flatMap(ann -> ann.stringValue("className"))
   .map(s -> baseTypeInfo.className().peerClass(s))
   .get();
}

代码示例来源:origin: com.google.dagger/dagger-compiler

/** The name of the class that hosts the module constructor proxy method. */
static ClassName constructorProxyTypeName(TypeElement moduleElement) {
 ModuleKind.checkIsModule(moduleElement);
 ClassName moduleClassName = ClassName.get(moduleElement);
 return moduleClassName
   .topLevelClassName()
   .peerClass(SourceFiles.classFileName(moduleClassName) + "_Proxy");
}

代码示例来源:origin: br.com.objectos.way/pojo-plugin

@Override
public ClassName builderClass() {
 return superClass().peerClass(superClass().simpleName() + "Builder");
}

代码示例来源:origin: br.com.objectos.way/pojo-plugin

@Override
public ClassName builderInterface() {
 return superClass().peerClass(superClass().simpleName() + "BuilderDsl");
}

代码示例来源:origin: com.google.dagger/dagger-compiler

/**
 * Returns the name of the creator class for this component. It will be a sibling of this
 * generated class unless this is a top-level component, in which case it will be nested.
 */
ClassName getCreatorName() {
 return isNested()
   ? name.peerClass(subcomponentNames.get(componentDescriptor()) + "Builder")
   : name.nestedClass("Builder");
}

代码示例来源:origin: br.com.objectos.way/io-flat-pojo-plugin

public static RecordInfo code(PojoInfo pojoInfo) {
 Naming naming = pojoInfo.naming();
 ClassName className = naming.superClass();
 ClassName classNameParser = className.peerClass(className.simpleName() + "Parser");
 TypeName typeNameMatcherInterface = ClassName.get(br.com.objectos.way.io.flat.RecordMatcher.class);
 TypeName typeNameParserInterface = ParameterizedTypeName.get(ClassName.get(RecordParser.class), className);
 List<FieldMethod> fieldMethodList;
 fieldMethodList = FieldMethod.fieldMethodListOf(pojoInfo);
 return new RecordInfo(
   pojoInfo.naming().superClassTypeName(),
   pojoInfo.naming().builderClassName(),
   classNameParser,
   typeNameMatcherInterface,
   typeNameParserInterface,
   fieldMethodList);
}

相关文章