Skip to content

Commit 40af55d

Browse files
committed
refactor: Fix warnings in CRD generator code
1 parent 623d9d1 commit 40af55d

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractCustomResourceHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private TypeDef visitTypeDefInParallel(TypeDef def, List<Visitor<TypeDefBuilder>
159159
* @param format the format of the printer column
160160
* @return the concrete decorator implementing the addition of a printer column to the currently built CRD
161161
*/
162-
protected abstract Decorator getPrinterColumnDecorator(String name, String version, String path,
162+
protected abstract Decorator<?> getPrinterColumnDecorator(String name, String version, String path,
163163
String type, String column, String description, String format, int priority);
164164

165165
/**

crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private static ClassRef extractClassRef(Object type) {
213213
if (type instanceof ClassRef) {
214214
return (ClassRef) type;
215215
} else if (type instanceof Class) {
216-
return Types.typeDefFrom((Class) type).toReference();
216+
return Types.typeDefFrom((Class<?>) type).toReference();
217217
} else {
218218
throw new IllegalArgumentException("Unmanaged type passed to the annotation " + type);
219219
}
@@ -564,7 +564,7 @@ public Property process() {
564564
String finalName = renamedTo != null ? renamedTo : original.getName();
565565

566566
return new Property(original.getAnnotations(), typeRef, finalName,
567-
original.getComments(), original.getModifiers(), original.getAttributes());
567+
original.getComments(), false, false, original.getModifiers(), original.getAttributes());
568568
}
569569
}
570570

@@ -653,6 +653,7 @@ private T internalFromImpl(String name, TypeRef typeRef, Set<String> visited, In
653653
// Note that ordering of the checks here is meaningful: we need to check for complex types last
654654
// in case some "complex" types are handled specifically
655655
if (typeRef.getDimensions() > 0 || io.sundr.model.utils.Collections.isCollection(typeRef)) { // Handle Collections & Arrays
656+
//noinspection unchecked
656657
final TypeRef collectionType = TypeAs.combine(TypeAs.UNWRAP_ARRAY_OF, TypeAs.UNWRAP_COLLECTION_OF)
657658
.apply(typeRef);
658659
final T schema = internalFromImpl(name, collectionType, visited, schemaSwaps);

crd-generator/api/src/main/java/io/fabric8/crd/generator/CustomResourceInfo.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public class CustomResourceInfo {
4545
private final Scope scope;
4646
private final TypeDef definition;
4747
private final String crClassName;
48-
private final Optional<String> specClassName;
49-
private final Optional<String> statusClassName;
48+
private final String specClassName;
49+
private final String statusClassName;
5050
private final String id;
5151
private final int hash;
5252

@@ -68,8 +68,8 @@ public CustomResourceInfo(String group, String version, String kind, String sing
6868
this.scope = scope;
6969
this.definition = definition;
7070
this.crClassName = crClassName;
71-
this.specClassName = Optional.ofNullable(specClassName);
72-
this.statusClassName = Optional.ofNullable(statusClassName);
71+
this.specClassName = specClassName;
72+
this.statusClassName = statusClassName;
7373
this.id = crdName() + "/" + version;
7474
this.hash = id.hashCode();
7575
this.annotations = annotations;
@@ -125,11 +125,11 @@ public String crClassName() {
125125
}
126126

127127
public Optional<String> specClassName() {
128-
return specClassName;
128+
return Optional.ofNullable(specClassName);
129129
}
130130

131131
public Optional<String> statusClassName() {
132-
return statusClassName;
132+
return Optional.ofNullable(statusClassName);
133133
}
134134

135135
public TypeDef definition() {
@@ -144,9 +144,9 @@ public String[] labels() {
144144
return labels;
145145
}
146146

147-
public static CustomResourceInfo fromClass(Class<? extends CustomResource> customResource) {
147+
public static CustomResourceInfo fromClass(Class<? extends CustomResource<?, ?>> customResource) {
148148
try {
149-
final CustomResource instance = customResource.getDeclaredConstructor().newInstance();
149+
final CustomResource<?, ?> instance = customResource.getDeclaredConstructor().newInstance();
150150

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

crd-generator/api/src/main/java/io/fabric8/crd/generator/InternalSchemaSwaps.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public InternalSchemaSwaps branchDepths() {
5050
public InternalSchemaSwaps branchAnnotations() {
5151
Map<Key, Value> combined = new HashMap<>(swaps);
5252
combined.putAll(parentSwaps);
53-
InternalSchemaSwaps result = new InternalSchemaSwaps(new HashMap<>(), this.swapDepths, combined);
54-
return result;
53+
return new InternalSchemaSwaps(new HashMap<>(), this.swapDepths, combined);
5554
}
5655

5756
public void registerSwap(ClassRef definitionType, ClassRef originalType, String fieldName, ClassRef targetType,

crd-generator/api/src/main/java/io/fabric8/crd/generator/v1/CustomResourceHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public CustomResourceHandler(Resources resources, boolean parallel) {
4545
}
4646

4747
@Override
48-
protected Decorator getPrinterColumnDecorator(String name,
48+
protected Decorator<?> getPrinterColumnDecorator(String name,
4949
String version, String path,
5050
String type, String column, String description, String format, int priority) {
5151
return new AddAdditionPrinterColumnDecorator(name, version, type, column, path, format,

crd-generator/api/src/main/java/io/fabric8/crd/generator/v1beta1/CustomResourceHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public CustomResourceHandler(Resources resources, boolean parallel) {
4545
}
4646

4747
@Override
48-
protected Decorator getPrinterColumnDecorator(
48+
protected Decorator<?> getPrinterColumnDecorator(
4949
String name, String version, String path, String type, String column,
5050
String description, String format, int priority) {
5151
return new AddAdditionPrinterColumnDecorator(name, version, type, column, path, format,

0 commit comments

Comments
 (0)