private static Naming of0(TypeInfo typeInfo) { return new Naming( typeInfo.className(), typeInfo.classNameSuffix("Pojo"), typeInfo.classNameSuffix("Builder"), typeInfo.classNameSuffix("BuilderPojo"), typeInfo.typeVariableNameList(), typeInfo.typeVariableNameRawList(), typeInfo.typeVariableNameUnboundedList()); }
@Override public String toString() { return qualifiedName(); }
public Stream<MethodInfo> methodInfoStream() { return typeInfo.methodInfoStream(); }
@Override public Stream<AnnotationInfo> annotationInfoStream() { Stream<AnnotationInfo> superTypeStream = superTypeInfoAnnotationStream(); Stream<AnnotationInfo> interfaceStream = interfaceInfoMap().annotationInfoStream(); Set<String> nameSet = annotationInfoList().stream() .map(AnnotationInfo::qualifiedName) .collect(Collectors.toSet()); Stream<AnnotationInfo> superStream = Stream.concat(superTypeStream, interfaceStream) .filter(m -> nameSet.add(m.qualifiedName())); return Stream.concat(superStream, annotationInfoList().stream()); }
@Override public Equality isEqualTo(Object that) { return Tester.of(TypeInfo.class) .add("accessInfo", o -> o.accessInfo()) .add("kind", o -> o.kind()) .add("packageInfo", o -> o.packageInfo()) .add("name", o -> o.name()) .add("typeParameterInfoMap", o -> o.typeParameterInfoMap()) .add("annotationInfoList", o -> o.annotationInfoList()) .add("enclosingSimpleTypeInfo", o -> o.enclosingSimpleTypeInfo()) .add("superTypeInfo", o -> o.superTypeInfo()) .add("interfaceInfoMap", o -> o.interfaceInfoMap()) .add("fieldInfoList", o -> o.fieldInfoList()) .add("constructorInfoList", o -> o.constructorInfoList()) .add("methodInfoList", o -> o.methodInfoList()) .add("declaredTypeInfoList", o -> o.declaredTypeInfoList()) .test(this, that); }
public static BaseTypeType of(TypeInfo typeInfo) { return new BaseTypeType( typeInfo.className(), typeInfo.annotationInfo(BaseType.class) .flatMap(ann -> ann.stringValue("className")) .get(), typeInfo.methodInfoStream() .map(AttributeMethod::of) .collect(Collectors.toList())); }
public static CsvReaderType of(TypeInfo typeInfo) { AnnotationInfo csvRecord = typeInfo.annotationInfo(CsvRecord.class).get(); return CsvReaderType.builder() .superClass(typeInfo.className()) .pojo(typeInfo.classNameSuffix("Pojo")) .reader(typeInfo.classNameSuffix("Reader")) .separator(csvRecord.enumConstantInfoValue("separator") .map(info -> info.getEnumValue(Separator.class)) .get()) .skip(csvRecord.annotationValueInfo("skip") .get() .intValue()) .encoding(csvRecord.enumConstantInfoValue("encoding") .map(info -> info.getEnumValue(Encoding.class)) .get()) .build(); }
public static RepoType of(TypeInfo typeInfo) { List<RepoQueryMethod> queryMethodList = typeInfo.methodInfoStream() .filter(m -> m.hasAnnotation(Query.class)) .map(RepoQueryMethod::ofRepo) .filter(Optional::isPresent) .map(Optional::get) .collect(MoreCollectors.toImmutableList()); return RepoType.builder() .superTypeName(typeInfo.typeName()) .repoClassName(typeInfo.classNameSuffix("Repo")) .queryMethodList(queryMethodList) .build(); }
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(); }
String tagName() { return typeInfo.simpleName(); }
private static BindType ofBoolean(SimpleTypeInfo returnTypeInfo, TypeInfo columnClassTypeInfo) { String simpleName = columnClassTypeInfo.annotationInfo(ValueType.class) .flatMap(ann -> ann.simpleTypeInfoValue("value")) .map(SimpleTypeInfo::simpleName) .orElse(""); return "int".equals(simpleName) ? BOOLEAN_INT : STANDARD; }
public ClassName className() { return typeInfo.className(); }
private static SuperTypeInfo superTypeInfo(TypeInfo typeInfo) { return TestingSuperTypeInfo.builder() .annotationInfoList(typeInfo.annotationInfoList()) .superTypeInfo(typeInfo.superTypeInfo()) .interfaceInfoMap(typeInfo.interfaceInfoMap()) .methodInfoList(typeInfo.methodInfoList()) .build(); }
private static String classSimpleName(TypeInfo typeInfo) { String simpleName = typeInfo.annotationInfo(ProtoType.class) .flatMap(annotationInfo -> annotationInfo.stringValue("className")) .get(); return "".equals(simpleName) ? Code.upperCaseFirstChar(typeInfo.simpleName()) : simpleName; }
private Artifact iface(TypeInfo typeInfo, String message) { ClassName className = typeInfo.classNameSuffix("Message"); TypeSpec typeSpec = TypeSpec.interfaceBuilder(className) .addAnnotation(AnnotationSpec.builder(Message.class) .addMember("value", "$S", message) .build()) .build(); JavaFile javaFile = typeInfo.toJavaFile(typeSpec); return Artifact.of(javaFile); }
private static BindType ofEnum(SimpleTypeInfo returnTypeInfo, TypeInfo columnClassTypeInfo) { EnumType enumType = columnClassTypeInfo.annotationInfo(EnumColumn.class) .flatMap(ann -> ann.enumConstantInfoValue("value")) .map(info -> info.getEnumValue(EnumType.class)) .orElse(EnumType.VOID); switch (enumType) { default: case ORDINAL: return ENUM_ORDINAL; case STRING: return returnTypeInfo.typeInfo().get().getInterface(EnumSql.class).isPresent() ? ENUM_SQL : ENUM_STRING; } }
private ContentModel contentModel() { return typeInfo.hasAnnotation(Void.class) ? ContentModel.VOID : ContentModel.NON_VOID; }
public static ColumnInfoTypeInfo of(TableName tableName, TypeInfo typeInfo) { return ColumnInfoTypeInfo.builder() .tableName(tableName) .simpleName(stringValue(typeInfo, ColumnName.class)) .nullable(typeInfo.hasAnnotation(Nullable.class)) .generationInfo(OrmGenerationInfo.of(typeInfo)) .simpleTypeInfo(typeInfo.toSimpleTypeInfo()) .build(); }
public ClassName classNameSuffix(String suffix) { return typeInfo.classNameSuffix(suffix); }
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")); }