Skip to content

Commit

Permalink
Merge pull request quarkusio#38679 from metacosm/builder
Browse files Browse the repository at this point in the history
Add convenience methods mirroring ReflectiveClassBuildItem factory methods
  • Loading branch information
gastaldi authored Feb 9, 2024
2 parents 3077c2e + 9f0a591 commit d80aa32
Showing 1 changed file with 63 additions and 0 deletions.
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

0 comments on commit d80aa32

Please sign in to comment.