public static Column of(AnnotationInfo annotationInfo) { return new Column( annotationInfo.enclosingTypeInfo().get().simpleName(), annotationInfo.simpleName(), annotationInfo.annotationValueInfo("orderBy") .map(value -> value.enumValue(SortOrder.class)) .orElse(SortOrder.ASC)); }
public static GenerationType of(AnnotationInfo columnAnnotationInfo) { return columnAnnotationInfo.annotationInfo(GeneratedValue.class) .flatMap(ann -> ann.enumConstantInfoValue("value")) .map(value -> value.getEnumValue(GenerationKind.class)) .map(kind -> GenerationType.valueOf(kind.name())) .orElse(GenerationType.NONE); }
@Override public boolean matches(AnnotationInfo annotationInfo) { return annotationInfo.simpleTypeInfo().equals(columnAnnotationInfo().simpleTypeInfo()); }
private List<ColumnOrmProperty> referencedPropertyList0(OrmPojoInfo returnPojoInfo) { return foreignKeyAnnotationInfo() .annotationInfo(ReferencesAnnotationClassArray.class) .flatMap(ann -> ann.simpleTypeInfoArrayValue("value")) .map(list -> list.stream() .map(typeInfo -> returnPojoInfo.columnPropertyAnnotatedWith(typeInfo)) .filter(Optional::isPresent) .map(Optional::get) .collect(MoreCollectors.toImmutableList())) .get(); }
.annotationInfo(ColumnSeq.class) .flatMap(ann -> ann.annotationValueInfo("value")); if (value.isPresent()) { columnSeq = value.get().intValue(); .annotationInfo(ColumnClass.class) .flatMap(annotationInfo -> annotationInfo.simpleTypeInfoValue("value")) .flatMap(typeInfo -> typeInfo.typeInfo()) .get(); .returnType(returnTypeHelper.returnType()) .tableInfo(TableInfoAnnotationInfo.of(columnAnnotationInfo)) .columnAnnotationClassList(ImmutableList.of(columnAnnotationInfo.simpleTypeInfo())) .columnSeq(columnSeq) .columnAnnotationInfo(columnAnnotationInfo) .columnClassName(columnClassTypeInfo.className()) .columnSimpleName(columnAnnotationInfo .annotationInfo(ColumnName.class) .flatMap(ann -> ann.stringValue("value")) .get()) .bindType(returnTypeHelper.bindType(columnClassTypeInfo))
public ConstructorStatementWriter setColumnAnnotationSimpleName() { builder.set(columnAnnotationInfo().simpleName()); return this; }
public Optional<String> stringValue(String name) { return annotationValueInfo(name) .map(AnnotationValueInfo::stringValue); }
private String stringValue(Class<? extends Annotation> type) { return typeInfo.annotationInfo(type) .flatMap(ann -> ann.stringValue("value")) .get(); }
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(); }
public static AttributeAnnotation of(AnnotationInfo annotationInfo) { String name = annotationInfo.stringValue("name").get(); String maybeIdentifier = annotationInfo.stringValue("identifier").get(); String identifier = Strings.isNullOrEmpty(maybeIdentifier) ? name : maybeIdentifier; return AttributeAnnotation.builder() .name(name) .identifier(identifier) .typeName(annotationInfo.simpleTypeInfoValue("type").get().typeName()) .build(); }
public <E extends Enum<E>> E enumValue(Class<E> enumType, String name, E defaultValue) { Objects.requireNonNull(enumType); Objects.requireNonNull(name); Objects.requireNonNull(defaultValue); return enumConstantInfoValue(name).map(info -> info.getEnumValue(enumType)).orElse(defaultValue); }
private Stream<ChildType> childTypeStream(String name, Function<TypeInfo, ChildType> mapper) { return protoTypeAnnotationInfo.simpleTypeInfoArrayValue(name) .orElse(ImmutableList.of()) .stream() .map(SimpleTypeInfo::typeInfo) .map(Optional::get) .map(mapper); }
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; }
@Override void acceptSetterMethodBody(CodeBlock.Builder body, SetterParameter parameter) { body.add(",\n $T.get().$L($L)", tableInfo().className(), columnAnnotationInfo().simpleName(), parameter.name()); }
public Optional<EnumConstantInfo> enumConstantInfoValue(String name) { return annotationValueInfo(name) .map(AnnotationValueInfo::enumConstantInfoValue); }
private static String stringValue(TypeInfo typeInfo, Class<? extends Annotation> type) { return typeInfo.annotationInfo(type) .flatMap(annotationInfo -> annotationInfo.stringValue("value")) .get(); }
public static CsvRecordReturnType of(MethodInfo methodInfo, SimpleTypeInfo returnTypeInfo) { LocalDatePattern pattern = methodInfo.annotationInfo(LocalDateFormat.class) .flatMap(ann -> ann.enumConstantInfoValue("value")) .map(info -> info.getEnumValue(LocalDatePattern.class)) .orElse(LocalDatePattern.DD_MM_YYYY); return new LocalDateCsvRecordReturnType(pattern); }
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()); }
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); }