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; }
private String stringValue(Class<? extends Annotation> type) { return typeInfo.annotationInfo(type) .flatMap(ann -> ann.stringValue("value")) .get(); }
private static String stringValue(TypeInfo typeInfo, Class<? extends Annotation> type) { return typeInfo.annotationInfo(type) .flatMap(annotationInfo -> annotationInfo.stringValue("value")) .get(); }
Stream<ClassName> columnClassNameStream() { return columnAnnotationClassList().stream() .map(SimpleTypeInfo::typeInfo) .filter(Optional::isPresent) .map(Optional::get) .map(typeInfo -> typeInfo.annotationInfo(ColumnClass.class).get()) .map(ann -> ann.simpleTypeInfoValue("value").get()) .map(SimpleTypeInfo::className); }
public static List<ColumnInfoTypeInfo> listOf(TableName tableName, TypeInfo typeInfo) { return typeInfo.annotationInfo(ColumnAnnotationClassArray.class) .flatMap(ann -> ann.simpleTypeInfoArrayValue("value")) .get().stream() .map(SimpleTypeInfo::typeInfo) .filter(Optional::isPresent) .map(Optional::get) .map(it -> of(tableName, it)) .collect(MoreCollectors.toImmutableList()); }
private ProtoTypeType(TypeInfo typeInfo) { this.typeInfo = typeInfo; protoTypeAnnotationInfo = typeInfo.annotationInfo(ProtoType.class).get(); naming = ProtoTypeNaming.of(typeInfo); maxLevel = protoTypeAnnotationInfo.intValue("maxLevel", 6); }
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())); }
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 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(); }
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; } }
@Override public CodeBlock onForeignKey(ForeignKeyOrmProperty property) { String columnName = property.columnAnnotationClassList().get(0) .typeInfo() .flatMap(t -> t.annotationInfo(ColumnName.class)) .flatMap(ann -> ann.stringValue("value")) .get(); return CodeBlock.builder() .add(",\n $L(rs, $S)", name(property), columnName) .build(); }
public ReturnTypeAdapterPojo(ForeignKeyOrmProperty property) { fieldName = property.property().name(); columnName = property.columnAnnotationClassList().get(0) .typeInfo() .flatMap(t -> t.annotationInfo(ColumnName.class)) .flatMap(ann -> ann.stringValue("value")) .get(); ColumnOrmProperty refMethod = property.referencedPropertyList().get(0); propertyAccessor = refMethod.property().accessorName(); bindTypeAccessor = refMethod.bindType().accessor(); }
private static TableInfoAnnotationInfo of0(ClassName className, TypeInfo tableTypeInfo) { TableName tableName = TableNameAnnotationInfo.of(tableTypeInfo); return TableInfoAnnotationInfo.thisBuilder() .className(className) .tableName(tableName) .columnInfoList(ColumnInfoTypeInfo.listOf(tableName, tableTypeInfo)) .primaryKeyClassNameSet(tableTypeInfo.annotationInfo(PrimaryKeyClassArray.class) .flatMap(ann -> ann.simpleTypeInfoArrayValue("value")) .map(list -> list.stream() .map(SimpleTypeInfo::className) .collect(MoreCollectors.toImmutableSet())) .orElse(ImmutableSet.of())) .build(); }
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 ForeignKeyOrmProperty of(Property property, AnnotationInfo foreignKeyAnnotationInfo) { List<SimpleTypeInfo> columnAnnotationClassList = foreignKeyAnnotationInfo .annotationInfo(ColumnAnnotationClassArray.class) .flatMap(ann -> ann.simpleTypeInfoArrayValue("value")) .get(); return ForeignKeyOrmProperty.builder() .property(property) .returnType(ReturnTypeHelper.of(property.returnTypeInfo()).returnType()) .tableInfo(TableInfoAnnotationInfo.of(foreignKeyAnnotationInfo)) .columnAnnotationClassList(columnAnnotationClassList) .columnSeq(columnAnnotationClassList.get(0) .typeInfo() .flatMap(t -> t.annotationInfo(ColumnSeq.class)) .flatMap(ann -> ann.annotationValueInfo("value")) .get() .intValue()) .foreignKeyAnnotationInfo(foreignKeyAnnotationInfo) .build(); }