From 96232657df0d61f88df29ef313af84f148833bf5 Mon Sep 17 00:00:00 2001 From: Dusan Jakub Date: Fri, 26 Aug 2022 15:23:51 +0200 Subject: [PATCH] javadocs on annotations. fabric8io/kubernetes-client#4350 --- .../crd/generator/annotation/SchemaSwap.java | 28 ++++++++++++++++++- .../crd/generator/annotation/SchemaSwaps.java | 3 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwap.java b/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwap.java index 6a7c7b7f8fb..86e889edaf2 100644 --- a/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwap.java +++ b/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwap.java @@ -17,13 +17,39 @@ import java.lang.annotation.*; -@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE, ElementType.TYPE }) +/** + * Annotation that allows replacing a nested schema with one from another class. + * + * This is an alternative to {@link SchemaFrom} for cases when the classes + * are coming from an external source and fields cannot be annotated directly. + * + * @see SchemaFrom + */ +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(SchemaSwaps.class) public @interface SchemaSwap { + /** + * The owning class of the field whose type is to be replaced. + *

+ * It is an error if the type is not used in the same schema hierarchy where the {@link SchemaSwap} is used. + */ Class originalType(); + /** + * Name of the field whose type is to be replaced. + *

+ * The name should be specified exactly as defined in the Java class, before any renames + * and transformations ({@code @JsonProperty} and similar) take place. + *

+ * It is an error if the field does not exist on {@link #originalType()} + */ String fieldName(); + /** + * The replacement schema that will be used for the {@link #fieldName()} instead of its specified type + *

+ * The default value of {@code void.class} causes the field to be skipped + */ Class targetType() default void.class; } diff --git a/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwaps.java b/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwaps.java index c734e473187..fb99288d4e3 100644 --- a/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwaps.java +++ b/crd-generator/api/src/main/java/io/fabric8/crd/generator/annotation/SchemaSwaps.java @@ -20,6 +20,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * A container for multiple {@link SchemaSwap}s + */ @Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) public @interface SchemaSwaps {