Skip to content

Commit

Permalink
Fix @SchemaSwaps in apt context. fabric8io#4350
Browse files Browse the repository at this point in the history
  • Loading branch information
xRodney committed Aug 25, 2022
1 parent 20be2a8 commit 88fd5c1
Showing 1 changed file with 21 additions and 19 deletions.
Expand Up @@ -198,30 +198,32 @@ private void extractSchemaSwaps(ClassRef definitionType, AnnotationRef annotatio
case ANNOTATION_SCHEMA_SWAPS:
Map<String, Object> params = annotation.getParameters();
Object[] values = (Object[]) params.get("value");
if (values instanceof SchemaSwap[]) {
for (SchemaSwap value : (SchemaSwap[]) values) {
extractSchemaSwap(definitionType, value, schemaSwaps);
}
for (Object value : values) {
extractSchemaSwap(definitionType, value, schemaSwaps);
}
// for (AnnotationRef value : values) {
// extractSchemaSwap(definitionType, value, schemaSwaps);
// }
break;
}
}

private void extractSchemaSwap(ClassRef definitionType, AnnotationRef annotation, InternalSchemaSwaps schemaSwaps) {
Map<String, Object> params = annotation.getParameters();
schemaSwaps.registerSwap(definitionType,
extractClassRef(params.get("originalType")),
(String) params.get("fieldName"),
extractClassRef(params.get("targetType")));
}
private void extractSchemaSwap(ClassRef definitionType, SchemaSwap annotation, InternalSchemaSwaps schemaSwaps) {
schemaSwaps.registerSwap(definitionType,
extractClassRef(annotation.originalType()),
annotation.fieldName(),
extractClassRef(annotation.targetType()));
private void extractSchemaSwap(ClassRef definitionType, Object annotation, InternalSchemaSwaps schemaSwaps) {
if (annotation instanceof SchemaSwap) {
SchemaSwap schemaSwap = (SchemaSwap) annotation;
schemaSwaps.registerSwap(definitionType,
extractClassRef(schemaSwap.originalType()),
schemaSwap.fieldName(),
extractClassRef(schemaSwap.targetType()));

} else if (annotation instanceof AnnotationRef
&& ((AnnotationRef) annotation).getClassRef().getFullyQualifiedName().equals(ANNOTATION_SCHEMA_SWAP)) {
Map<String, Object> params = ((AnnotationRef) annotation).getParameters();
schemaSwaps.registerSwap(definitionType,
extractClassRef(params.get("originalType")),
(String) params.get("fieldName"),
extractClassRef(params.get("targetType")));

} else {
throw new IllegalArgumentException("Unmanaged annotation type passed to the SchemaSwaps: " + annotation);
}
}

private void validateRemainingSchemaSwaps(InternalSchemaSwaps schemaSwaps) {
Expand Down

0 comments on commit 88fd5c1

Please sign in to comment.