From 9f0a591d964e2a35792fe9f6a4f9d691c29b0d23 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 8 Feb 2024 14:02:19 +0100 Subject: [PATCH] Add convenience methods mirroring ReflectiveClassBuildItem factory methods Revert changes to call sites Add convenience methods mirroring ReflectiveClassBuildItem factory methods --- .../ReflectiveHierarchyBuildItem.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveHierarchyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveHierarchyBuildItem.java index 77ed4fba53079..bd13ee0931508 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveHierarchyBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveHierarchyBuildItem.java @@ -152,6 +152,49 @@ public String getSource() { return source; } + /** + * Creates a new {@link Builder} instance, using the specified class for the underlying {@link Type} which hierarchy is to + * be be registered for reflection. + * + * @param clazz the Class which hierarchy is to be registered for reflection + * @return a new {@link Builder} instance, initialized from the specified Class + */ + public static Builder builder(Class clazz) { + return builder(clazz.getName()); + } + + /** + * Creates a new {@link Builder} instance, using the specified class for the underlying {@link Type} which hierarchy is to + * be be registered for reflection. + * + * @param className the name of the Class which hierarchy is to be registered for reflection + * @return a new {@link Builder} instance, initialized from the specified Class + */ + public static Builder builder(String className) { + return builder(DotName.createSimple(className)); + } + + /** + * Creates a new {@link Builder} instance, using the specified class for the underlying {@link Type} which hierarchy is to + * be be registered for reflection. + * + * @param className the {@link DotName} of the Class which hierarchy is to be registered for reflection + * @return a new {@link Builder} instance, initialized from the specified Class + */ + public static Builder builder(DotName className) { + return builder(Type.create(className, Type.Kind.CLASS)); + } + + /** + * Creates a new {@link Builder} instance, initializing it with the specified {@link Type} + * + * @param type the {@link Type} which hierarchy is to be registered for reflection + * @return a new {@link Builder} instance, initialized from the specified {@link Type} + */ + public static Builder builder(Type type) { + return new Builder().type(type); + } + public static class Builder { private Type type; @@ -167,6 +210,26 @@ public Builder type(Type type) { return this; } + /** + * Derives the target {@link Type} to be registered from the specified class name. + * + * @param className a {@link DotName} representing the name of the class of the Type to be registered for reflection + * @return this {@link Builder} instance + */ + public Builder className(DotName className) { + return type(Type.create(className, Type.Kind.CLASS)); + } + + /** + * Derives the target {@link Type} to be registered from the specified class name. + * + * @param className the name of the class of the Type to be registered for reflection + * @return this {@link Builder} instance + */ + public Builder className(String className) { + return className(DotName.createSimple(className)); + } + public Builder index(IndexView index) { this.index = index; return this;