use of org.apache.beam.sdk.schemas.annotations.SchemaFieldName in project beam by apache.
the class FieldValueTypeInformation method getNameOverride.
public static <T extends AnnotatedElement & Member> String getNameOverride(String original, T member) {
@Nullable SchemaFieldName fieldName = member.getAnnotation(SchemaFieldName.class);
@Nullable SchemaCaseFormat caseFormatAnnotation = member.getAnnotation(SchemaCaseFormat.class);
@Nullable SchemaCaseFormat classCaseFormatAnnotation = member.getDeclaringClass().getAnnotation(SchemaCaseFormat.class);
if (fieldName != null) {
if (caseFormatAnnotation != null) {
throw new RuntimeException(String.format("Cannot define both @SchemaFieldName and @SchemaCaseFormat. From member '%s'.", member.getName()));
}
return fieldName.value();
} else if (caseFormatAnnotation != null) {
return CaseFormat.LOWER_CAMEL.to(caseFormatAnnotation.value(), original);
} else if (classCaseFormatAnnotation != null) {
return CaseFormat.LOWER_CAMEL.to(classCaseFormatAnnotation.value(), original);
} else {
return original;
}
}
Aggregations