Skip to content

Commit 9076148

Browse files
committed
refactor: clean-up
Signed-off-by: Chris Laprun <claprun@redhat.com>
1 parent 0fd5c03 commit 9076148

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static boolean inheritsNamespacesFromController(Set<String> namespaces) {
152152
class InformerConfigurationBuilder<R extends HasMetadata> {
153153

154154
private final Class<R> resourceClass;
155-
private GroupVersionKind groupVersionKind;
155+
private final GroupVersionKind groupVersionKind;
156156
private final Class<? extends HasMetadata> primaryResourceClass;
157157
private String name;
158158
private PrimaryToSecondaryMapper<?> primaryToSecondaryMapper;
@@ -252,6 +252,7 @@ public <P extends HasMetadata> InformerConfigurationBuilder<R> withWatchCurrentN
252252
* controller's namespaces are reconfigured, {@code false} otherwise
253253
* @return the builder instance so that calls can be chained fluently
254254
*/
255+
@SuppressWarnings("UnusedReturnValue")
255256
public InformerConfigurationBuilder<R> followControllerNamespacesOnChange(
256257
boolean followChanges) {
257258
this.followControllerNamespacesOnChange = followChanges;
@@ -263,6 +264,7 @@ public InformerConfigurationBuilder<R> withLabelSelector(String labelSelector) {
263264
return this;
264265
}
265266

267+
@SuppressWarnings("UnusedReturnValue")
266268
public InformerConfigurationBuilder<R> withOnAddFilter(OnAddFilter<? super R> onAddFilter) {
267269
this.onAddFilter = onAddFilter;
268270
return this;
@@ -274,12 +276,14 @@ public InformerConfigurationBuilder<R> withOnUpdateFilter(
274276
return this;
275277
}
276278

279+
@SuppressWarnings("UnusedReturnValue")
277280
public InformerConfigurationBuilder<R> withOnDeleteFilter(
278281
OnDeleteFilter<? super R> onDeleteFilter) {
279282
this.onDeleteFilter = onDeleteFilter;
280283
return this;
281284
}
282285

286+
@SuppressWarnings("UnusedReturnValue")
283287
public InformerConfigurationBuilder<R> withGenericFilter(
284288
GenericFilter<? super R> genericFilter) {
285289
this.genericFilter = genericFilter;

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResourceConfigBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public final class KubernetesDependentResourceConfigBuilder<R extends HasMetadat
1212

1313
public KubernetesDependentResourceConfigBuilder() {}
1414

15+
@SuppressWarnings("unused")
1516
public KubernetesDependentResourceConfigBuilder<R> withCreateResourceOnlyIfNotExistingWithSSA(
1617
boolean createResourceOnlyIfNotExistingWithSSA) {
1718
this.createResourceOnlyIfNotExistingWithSSA = createResourceOnlyIfNotExistingWithSSA;
@@ -29,7 +30,6 @@ public KubernetesDependentResourceConfigBuilder<R> withInformerConfiguration(
2930
return this;
3031
}
3132

32-
@SuppressWarnings("unchecked")
3333
public KubernetesDependentResourceConfig<R> build() {
3434
return new KubernetesDependentResourceConfig<>(
3535
useSSA, createResourceOnlyIfNotExistingWithSSA,

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ControllerConfigurationOverriderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ void shouldBePossibleToForceDependentToWatchAllNamespaces() {
237237
}
238238

239239
@Test
240+
@SuppressWarnings("unchecked")
240241
void overridingNamespacesShouldBePropagatedToDependentsWithDefaultConfig() {
241242
var configuration = createConfiguration(new OneDepReconciler());
242243
// retrieve the config for the first (and unique) dependent
@@ -277,8 +278,8 @@ void alreadyOverriddenDependentNamespacesShouldNotBePropagated() {
277278
config.informerConfiguration().getNamespaces());
278279
}
279280

280-
@SuppressWarnings("rawtypes")
281281
@Test
282+
@SuppressWarnings({"rawtypes", "unchecked"})
282283
void replaceNamedDependentResourceConfigShouldWork() {
283284
var configuration = createConfiguration(new OneDepReconciler());
284285
var dependents = configuration.getWorkflowSpec().orElseThrow().getDependentResourceSpecs();

operator-framework/src/test/java/io/javaoperatorsdk/operator/config/BaseConfigurationServiceTest.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void defaultValuesShouldBeConsistent() {
7474
assertNull(unannotated.informerConfiguration().getLabelSelector());
7575
}
7676

77-
@SuppressWarnings("rawtypes")
77+
@SuppressWarnings({"rawtypes", "unchecked"})
7878
private static KubernetesDependentResourceConfig extractDependentKubernetesResourceConfig(
7979
io.javaoperatorsdk.operator.api.config.ControllerConfiguration<?> configuration, int index) {
8080
final var spec =
@@ -83,7 +83,7 @@ private static KubernetesDependentResourceConfig extractDependentKubernetesResou
8383
}
8484

8585
@Test
86-
@SuppressWarnings("rawtypes")
86+
@SuppressWarnings({"rawtypes", "unchecked"})
8787
void getDependentResources() {
8888
var configuration = configFor(new NoDepReconciler());
8989
var workflowSpec = configuration.getWorkflowSpec();
@@ -226,11 +226,12 @@ void configuringFromCustomAnnotationsShouldWork() {
226226
assertEquals(CustomConfigConverter.CONVERTER_PROVIDED_DEFAULT, getValue(config, 1));
227227
}
228228

229+
@SuppressWarnings("unchecked")
229230
private static int getValue(
230231
io.javaoperatorsdk.operator.api.config.ControllerConfiguration<?> configuration, int index) {
231232
final var spec =
232233
configuration.getWorkflowSpec().orElseThrow().getDependentResourceSpecs().get(index);
233-
return ((CustomConfig) configuration.getConfigurationFor(spec)).getValue();
234+
return ((CustomConfig) configuration.getConfigurationFor(spec)).value();
234235
}
235236

236237
@ControllerConfiguration(
@@ -481,18 +482,7 @@ private static class ChildCustomAnnotatedDep extends CustomAnnotatedDep {
481482
int value();
482483
}
483484

484-
private static class CustomConfig {
485-
486-
private final int value;
487-
488-
private CustomConfig(int value) {
489-
this.value = value;
490-
}
491-
492-
public int getValue() {
493-
return value;
494-
}
495-
}
485+
private record CustomConfig(int value) {}
496486

497487
private static class CustomConfigConverter
498488
implements ConfigurationConverter<CustomAnnotation, CustomConfig> {

0 commit comments

Comments
 (0)