Skip to content

Commit

Permalink
refactor: Fix warnings in CRD generator code
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnerbart committed Aug 17, 2023
1 parent 2dc3354 commit 1c11ac2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private TypeDef visitTypeDefInParallel(TypeDef def, List<Visitor<TypeDefBuilder>
* @param format the format of the printer column
* @return the concrete decorator implementing the addition of a printer column to the currently built CRD
*/
protected abstract Decorator getPrinterColumnDecorator(String name, String version, String path,
protected abstract Decorator<?> getPrinterColumnDecorator(String name, String version, String path,
String type, String column, String description, String format, int priority);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static ClassRef extractClassRef(Object type) {
if (type instanceof ClassRef) {
return (ClassRef) type;
} else if (type instanceof Class) {
return Types.typeDefFrom((Class) type).toReference();
return Types.typeDefFrom((Class<?>) type).toReference();
} else {
throw new IllegalArgumentException("Unmanaged type passed to the annotation " + type);
}
Expand Down Expand Up @@ -564,7 +564,7 @@ public Property process() {
String finalName = renamedTo != null ? renamedTo : original.getName();

return new Property(original.getAnnotations(), typeRef, finalName,
original.getComments(), original.getModifiers(), original.getAttributes());
original.getComments(), false, false, original.getModifiers(), original.getAttributes());
}
}

Expand Down Expand Up @@ -653,6 +653,7 @@ private T internalFromImpl(String name, TypeRef typeRef, Set<String> visited, In
// Note that ordering of the checks here is meaningful: we need to check for complex types last
// in case some "complex" types are handled specifically
if (typeRef.getDimensions() > 0 || io.sundr.model.utils.Collections.isCollection(typeRef)) { // Handle Collections & Arrays
//noinspection unchecked
final TypeRef collectionType = TypeAs.combine(TypeAs.UNWRAP_ARRAY_OF, TypeAs.UNWRAP_COLLECTION_OF)
.apply(typeRef);
final T schema = internalFromImpl(name, collectionType, visited, schemaSwaps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class CustomResourceInfo {
private final Scope scope;
private final TypeDef definition;
private final String crClassName;
private final Optional<String> specClassName;
private final Optional<String> statusClassName;
private final String specClassName;
private final String statusClassName;
private final String id;
private final int hash;

Expand All @@ -68,8 +68,8 @@ public CustomResourceInfo(String group, String version, String kind, String sing
this.scope = scope;
this.definition = definition;
this.crClassName = crClassName;
this.specClassName = Optional.ofNullable(specClassName);
this.statusClassName = Optional.ofNullable(statusClassName);
this.specClassName = specClassName;
this.statusClassName = statusClassName;
this.id = crdName() + "/" + version;
this.hash = id.hashCode();
this.annotations = annotations;
Expand Down Expand Up @@ -125,11 +125,11 @@ public String crClassName() {
}

public Optional<String> specClassName() {
return specClassName;
return Optional.ofNullable(specClassName);
}

public Optional<String> statusClassName() {
return statusClassName;
return Optional.ofNullable(statusClassName);
}

public TypeDef definition() {
Expand All @@ -144,9 +144,9 @@ public String[] labels() {
return labels;
}

public static CustomResourceInfo fromClass(Class<? extends CustomResource> customResource) {
public static CustomResourceInfo fromClass(Class<? extends CustomResource<?, ?>> customResource) {
try {
final CustomResource instance = customResource.getDeclaredConstructor().newInstance();
final CustomResource<?, ?> instance = customResource.getDeclaredConstructor().newInstance();

final String[] shortNames = CustomResource.getShortNames(customResource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public InternalSchemaSwaps branchDepths() {
public InternalSchemaSwaps branchAnnotations() {
Map<Key, Value> combined = new HashMap<>(swaps);
combined.putAll(parentSwaps);
InternalSchemaSwaps result = new InternalSchemaSwaps(new HashMap<>(), this.swapDepths, combined);
return result;
return new InternalSchemaSwaps(new HashMap<>(), this.swapDepths, combined);
}

public void registerSwap(ClassRef definitionType, ClassRef originalType, String fieldName, ClassRef targetType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public CustomResourceHandler(Resources resources, boolean parallel) {
}

@Override
protected Decorator getPrinterColumnDecorator(String name,
protected Decorator<?> getPrinterColumnDecorator(String name,
String version, String path,
String type, String column, String description, String format, int priority) {
return new AddAdditionPrinterColumnDecorator(name, version, type, column, path, format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public CustomResourceHandler(Resources resources, boolean parallel) {
}

@Override
protected Decorator getPrinterColumnDecorator(
protected Decorator<?> getPrinterColumnDecorator(
String name, String version, String path, String type, String column,
String description, String format, int priority) {
return new AddAdditionPrinterColumnDecorator(name, version, type, column, path, format,
Expand Down

0 comments on commit 1c11ac2

Please sign in to comment.