Skip to content

Commit 72c9cbf

Browse files
committed
refactor: move ConditionWithType to top level
Signed-off-by: Chris Laprun <claprun@redhat.com>
1 parent 60df558 commit 72c9cbf

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/AbstractWorkflowExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected synchronized void handleNodeExecutionFinish(
134134

135135
@SuppressWarnings("unchecked")
136136
protected <R> boolean isConditionMet(
137-
Optional<DependentResourceNode.ConditionWithType<R, P, ?>> condition,
137+
Optional<ConditionWithType<R, P, ?>> condition,
138138
DependentResourceNode<R, P> dependentResource) {
139139
final var dr = dependentResource.getDependentResource();
140140
return condition.map(c -> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.javaoperatorsdk.operator.processing.dependent.workflow;
2+
3+
import io.fabric8.kubernetes.api.model.HasMetadata;
4+
import io.javaoperatorsdk.operator.api.reconciler.Context;
5+
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
6+
7+
class ConditionWithType<R, P extends HasMetadata, T> implements ResultCondition<R, P, T> {
8+
private final Condition<R, P> condition;
9+
private final Type type;
10+
11+
ConditionWithType(Condition<R, P> condition, Type type) {
12+
this.condition = condition;
13+
this.type = type;
14+
}
15+
16+
public Type type() {
17+
return type;
18+
}
19+
20+
@SuppressWarnings("unchecked")
21+
@Override
22+
public Result<T> detailedIsMet(DependentResource<R, P> dependentResource, P primary,
23+
Context<P> context) {
24+
if (condition instanceof ResultCondition resultCondition) {
25+
return resultCondition.detailedIsMet(dependentResource, primary, context);
26+
} else {
27+
return Result
28+
.withoutResult(condition.isMet(dependentResource, primary, context));
29+
}
30+
}
31+
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.Optional;
66

77
import io.fabric8.kubernetes.api.model.HasMetadata;
8-
import io.javaoperatorsdk.operator.api.reconciler.Context;
98
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
109

1110
@SuppressWarnings("rawtypes")
@@ -20,32 +19,6 @@ class DependentResourceNode<R, P extends HasMetadata> {
2019
private ConditionWithType<R, P, ?> activationCondition;
2120
private final DependentResource<R, P> dependentResource;
2221

23-
static class ConditionWithType<R, P extends HasMetadata, T> implements ResultCondition<R, P, T> {
24-
private final Condition<R, P> condition;
25-
private final Type type;
26-
27-
ConditionWithType(Condition<R, P> condition, Type type) {
28-
this.condition = condition;
29-
this.type = type;
30-
}
31-
32-
public Type type() {
33-
return type;
34-
}
35-
36-
@SuppressWarnings("unchecked")
37-
@Override
38-
public Result<T> detailedIsMet(DependentResource<R, P> dependentResource, P primary,
39-
Context<P> context) {
40-
if (condition instanceof ResultCondition resultCondition) {
41-
return resultCondition.detailedIsMet(dependentResource, primary, context);
42-
} else {
43-
return ResultCondition.Result
44-
.withoutResult(condition.isMet(dependentResource, primary, context));
45-
}
46-
}
47-
}
48-
4922
DependentResourceNode(DependentResource<R, P> dependentResource) {
5023
this(null, null, null, null, dependentResource);
5124
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Detail<R> build() {
104104
}
105105

106106
DetailBuilder<R> withResultForCondition(
107-
DependentResourceNode.ConditionWithType conditionWithType,
107+
ConditionWithType conditionWithType,
108108
ResultCondition.Result conditionResult) {
109109
switch (conditionWithType.type()) {
110110
case ACTIVATION -> activationConditionResult = conditionResult;

0 commit comments

Comments
 (0)