Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience methods mirroring ReflectiveClassBuildItem factory methods #38679

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading