21
21
import io .fabric8 .kubernetes .api .model .LabelSelector ;
22
22
import io .fabric8 .kubernetes .api .model .LabelSelectorRequirement ;
23
23
import io .fabric8 .kubernetes .api .model .ObjectReference ;
24
- import io .fabric8 .kubernetes .client .dsl .FilterBuilder ;
24
+ import io .fabric8 .kubernetes .client .dsl .FilterNested ;
25
25
import io .fabric8 .kubernetes .client .dsl .FilterWatchListDeletable ;
26
26
import io .fabric8 .kubernetes .client .dsl .Resource ;
27
27
import io .fabric8 .kubernetes .client .utils .Utils ;
31
31
import java .util .List ;
32
32
import java .util .Map ;
33
33
34
- final class FilterBuilderImpl <T extends HasMetadata , L extends KubernetesResourceList <T >, R extends Resource <T >> implements FilterBuilder <FilterWatchListDeletable <T , L >> {
34
+ final class FilterNestedImpl <T extends HasMetadata , L extends KubernetesResourceList <T >, R extends Resource <T >> implements FilterNested <FilterWatchListDeletable <T , L >> {
35
35
36
36
private static final String INVOLVED_OBJECT_NAME = "involvedObject.name" ;
37
37
private static final String INVOLVED_OBJECT_NAMESPACE = "involvedObject.namespace" ;
@@ -44,10 +44,7 @@ final class FilterBuilderImpl<T extends HasMetadata, L extends KubernetesResourc
44
44
private final BaseOperation <T , L , R > baseOperation ;
45
45
private OperationContext context ;
46
46
47
- /**
48
- * @param baseOperation
49
- */
50
- FilterBuilderImpl (BaseOperation <T , L , R > baseOperation ) {
47
+ FilterNestedImpl (BaseOperation <T , L , R > baseOperation ) {
51
48
this .baseOperation = baseOperation ;
52
49
// create a context copy
53
50
context = this .baseOperation .context ;
@@ -63,38 +60,38 @@ final class FilterBuilderImpl<T extends HasMetadata, L extends KubernetesResourc
63
60
}
64
61
65
62
@ Override
66
- public FilterBuilder <FilterWatchListDeletable <T , L >> withLabels (Map <String , String > labels ) {
63
+ public FilterNested <FilterWatchListDeletable <T , L >> withLabels (Map <String , String > labels ) {
67
64
this .context .labels .putAll (labels );
68
65
return this ;
69
66
}
70
67
71
68
@ Override
72
- public FilterBuilder <FilterWatchListDeletable <T , L >> withoutLabels (Map <String , String > labels ) {
69
+ public FilterNested <FilterWatchListDeletable <T , L >> withoutLabels (Map <String , String > labels ) {
73
70
// Re-use "withoutLabel" to convert values from String to String[]
74
71
labels .forEach (this ::withoutLabel );
75
72
return this ;
76
73
}
77
74
78
75
@ Override
79
- public FilterBuilder <FilterWatchListDeletable <T , L >> withLabelIn (String key , String ... values ) {
76
+ public FilterNested <FilterWatchListDeletable <T , L >> withLabelIn (String key , String ... values ) {
80
77
context .labelsIn .put (key , values );
81
78
return this ;
82
79
}
83
80
84
81
@ Override
85
- public FilterBuilder <FilterWatchListDeletable <T , L >> withLabelNotIn (String key , String ... values ) {
82
+ public FilterNested <FilterWatchListDeletable <T , L >> withLabelNotIn (String key , String ... values ) {
86
83
context .labelsNotIn .put (key , values );
87
84
return this ;
88
85
}
89
86
90
87
@ Override
91
- public FilterBuilder <FilterWatchListDeletable <T , L >> withLabel (String key , String value ) {
88
+ public FilterNested <FilterWatchListDeletable <T , L >> withLabel (String key , String value ) {
92
89
context .labels .put (key , value );
93
90
return this ;
94
91
}
95
92
96
93
@ Override
97
- public FilterBuilder <FilterWatchListDeletable <T , L >> withoutLabel (String key , String value ) {
94
+ public FilterNested <FilterWatchListDeletable <T , L >> withoutLabel (String key , String value ) {
98
95
context .labelsNot .merge (key , new String []{value }, (oldList , newList ) -> {
99
96
final String [] concatList = (String []) Array .newInstance (String .class , oldList .length + newList .length );
100
97
System .arraycopy (oldList , 0 , concatList , 0 , oldList .length );
@@ -105,26 +102,26 @@ public FilterBuilder<FilterWatchListDeletable<T, L>> withoutLabel(String key, St
105
102
}
106
103
107
104
@ Override
108
- public FilterBuilder <FilterWatchListDeletable <T , L >> withFields (Map <String , String > fields ) {
105
+ public FilterNested <FilterWatchListDeletable <T , L >> withFields (Map <String , String > fields ) {
109
106
this .context .fields .putAll (fields );
110
107
return this ;
111
108
}
112
109
113
110
@ Override
114
- public FilterBuilder <FilterWatchListDeletable <T , L >> withField (String key , String value ) {
111
+ public FilterNested <FilterWatchListDeletable <T , L >> withField (String key , String value ) {
115
112
this .context .fields .put (key , value );
116
113
return this ;
117
114
}
118
115
119
116
@ Override
120
- public FilterBuilder <FilterWatchListDeletable <T , L >> withoutFields (Map <String , String > fields ) {
117
+ public FilterNested <FilterWatchListDeletable <T , L >> withoutFields (Map <String , String > fields ) {
121
118
// Re-use "withoutField" to convert values from String to String[]
122
119
fields .forEach (this ::withoutField );
123
120
return this ;
124
121
}
125
122
126
123
@ Override
127
- public FilterBuilder <FilterWatchListDeletable <T , L >> withoutField (String key , String value ) {
124
+ public FilterNested <FilterWatchListDeletable <T , L >> withoutField (String key , String value ) {
128
125
context .fieldsNot .merge (key , new String []{value }, (oldList , newList ) -> {
129
126
if (Utils .isNotNullOrEmpty (newList [0 ])) { // Only add new values when not null
130
127
final String [] concatList = (String []) Array .newInstance (String .class , oldList .length + newList .length );
@@ -139,7 +136,7 @@ public FilterBuilder<FilterWatchListDeletable<T, L>> withoutField(String key, St
139
136
}
140
137
141
138
@ Override
142
- public FilterBuilder <FilterWatchListDeletable <T , L >> withLabelSelector (LabelSelector selector ) {
139
+ public FilterNested <FilterWatchListDeletable <T , L >> withLabelSelector (LabelSelector selector ) {
143
140
Map <String , String > matchLabels = selector .getMatchLabels ();
144
141
if (matchLabels != null ) {
145
142
withLabels (matchLabels );
@@ -171,7 +168,7 @@ public FilterBuilder<FilterWatchListDeletable<T, L>> withLabelSelector(LabelSele
171
168
}
172
169
173
170
@ Override
174
- public FilterBuilder <FilterWatchListDeletable <T , L >> withInvolvedObject (ObjectReference objectReference ) {
171
+ public FilterNested <FilterWatchListDeletable <T , L >> withInvolvedObject (ObjectReference objectReference ) {
175
172
if (objectReference .getName () != null ) {
176
173
context .fields .put (INVOLVED_OBJECT_NAME , objectReference .getName ());
177
174
}
@@ -197,7 +194,7 @@ public FilterBuilder<FilterWatchListDeletable<T, L>> withInvolvedObject(ObjectRe
197
194
}
198
195
199
196
@ Override
200
- public FilterWatchListDeletable <T , L > build () {
197
+ public FilterWatchListDeletable <T , L > and () {
201
198
return this .baseOperation .newInstance (context );
202
199
}
203
200
}
0 commit comments