Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: David Kral <[email protected]>
  • Loading branch information
Verdent committed Jan 10, 2025
1 parent 3b9b03d commit 4bfe71d
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 76 deletions.
20 changes: 12 additions & 8 deletions common/common/src/main/java/io/helidon/common/GenericType.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public static <N> GenericType<N> create(N object) {
return GenericType.<N>create(object.getClass());
}

public static Builder builder() {
return new Builder();
}

private GenericType(Type type, Class<?> rawType) {
this.type = type;
this.rawType = rawType;
Expand Down Expand Up @@ -212,13 +216,13 @@ public String toString() {
return type.toString();
}

public static final class Builder<T> implements io.helidon.common.Builder<Builder<T>, GenericType<T>> {
public static final class Builder implements io.helidon.common.Builder<Builder, GenericType<?>> {

private Class<T> baseType;
private Class<?> baseType;
private List<GenericType<?>> genericParameters = new ArrayList<>();

@Override
public GenericType<T> build() {
public GenericType<?> build() {
if (baseType == null) {
throw new IllegalStateException("Base type has to be set");
}
Expand All @@ -230,23 +234,23 @@ public GenericType<T> build() {
return new GenericType<>(parameterizedType, baseType);
}

public Builder<T> baseType(Class<T> baseType) {
public Builder baseType(Class<?> baseType) {
this.baseType = baseType;
return this;
}

public Builder<T> genericParameters(List<GenericType<?>> genericParameters) {
public Builder genericParameters(List<GenericType<?>> genericParameters) {
this.genericParameters = genericParameters;
return this;
}

public Builder<T> addGenericParameter(GenericType<?> genericParameter) {
public Builder addGenericParameter(GenericType<?> genericParameter) {
this.genericParameters.add(genericParameter);
return this;
}

public Builder<T> addGenericParameter(Consumer<Builder<?>> consumer) {
Builder<?> builder = new Builder<>();
public Builder addGenericParameter(Consumer<Builder> consumer) {
Builder builder = new Builder();
consumer.accept(builder);
this.genericParameters.add(builder.build());
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static TypeName resolveGenerics(TypeName elementTypeName, TypeInfo typeI
return elementTypeName;
}

private static boolean needsResolving(TypeName typeName) {
static boolean needsResolving(TypeName typeName) {
for (TypeName typeArgument : typeName.typeArguments()) {
if (needsResolving(typeArgument)) {
return true;
Expand Down
Loading

0 comments on commit 4bfe71d

Please sign in to comment.