64
64
import jakarta .inject .Inject ;
65
65
66
66
public class DependentGen {
67
- private static final String FIELD_AUTHENTICATION = "authentication " ;
68
- private static final String VAR_WEB_CLIENT_SESSION = "webClientSession" ;
67
+ private static final String FIELD_CLIENT_PROVIDER = "clientProvider " ;
68
+ // private static final String VAR_WEB_CLIENT_SESSION = "webClientSession";
69
69
private static final String FIELD_API_CLIENT = "apiClient" ;
70
70
private static final String FIELD_NAME_VERTX = "vertx" ;
71
71
private static final String NAME_POSTFIX = "Dependent" ;
@@ -121,13 +121,9 @@ public void create() {
121
121
new SimpleName (PerResourcePollingDependentResource .class .getSimpleName ()),
122
122
new NodeList <>(resourceType , crdType ));
123
123
124
-
125
-
126
-
127
124
ClassOrInterfaceDeclaration clazz = cu .addClass (className , Keyword .PUBLIC )
128
125
.addExtendedType (dependentType );
129
126
130
-
131
127
fields (clazz );
132
128
constructor (clazz );
133
129
initClientMethod (clazz );
@@ -196,16 +192,16 @@ private void initClientMethod(ClassOrInterfaceDeclaration clazz) {
196
192
.addAnnotation (PostConstruct .class );
197
193
198
194
199
- ClassOrInterfaceType webClientSessionType = new ClassOrInterfaceType (null , WebClientSession .class .getSimpleName ());
200
- ClassOrInterfaceType webClientType = new ClassOrInterfaceType (null , WebClient .class .getSimpleName ());
195
+ // ClassOrInterfaceType webClientSessionType = new ClassOrInterfaceType(null, WebClientSession.class.getSimpleName());
196
+ // ClassOrInterfaceType webClientType = new ClassOrInterfaceType(null, WebClient.class.getSimpleName());
201
197
ClassOrInterfaceType vertxRequestAdapterType = new ClassOrInterfaceType (null , VertXRequestAdapter .class .getSimpleName ());
202
198
ClassOrInterfaceType apiClientType = new ClassOrInterfaceType (null , "ApiClient" );
203
199
204
200
NodeList <Statement > initClientStatements = new NodeList <>();
205
201
206
- initClientStatements .add (new ExpressionStmt (new AssignExpr (new VariableDeclarationExpr (webClientSessionType , VAR_WEB_CLIENT_SESSION ), new MethodCallExpr (new TypeExpr (webClientSessionType ), "create" , new NodeList <>(new MethodCallExpr (new TypeExpr (webClientType ), "create" , new NodeList <>(new NameExpr (FIELD_NAME_VERTX ))))), Operator .ASSIGN )));
207
- initClientStatements .add (new ExpressionStmt (new MethodCallExpr (new NameExpr (FIELD_AUTHENTICATION ), "addAuthHeaders " , new NodeList <>(new NameExpr ( VAR_WEB_CLIENT_SESSION ) ))));
208
- initClientStatements .add (new ExpressionStmt (new AssignExpr (new VariableDeclarationExpr (vertxRequestAdapterType , "requestAdapter" ), new ObjectCreationExpr (null , vertxRequestAdapterType , new NodeList <>(new NameExpr (VAR_WEB_CLIENT_SESSION ))), Operator .ASSIGN )));
202
+ // initClientStatements.add(new ExpressionStmt(new AssignExpr(new VariableDeclarationExpr(webClientSessionType, VAR_WEB_CLIENT_SESSION), new MethodCallExpr(new TypeExpr(webClientSessionType), "create", new NodeList<>(new MethodCallExpr(new TypeExpr(webClientType), "create", new NodeList<>(new NameExpr(FIELD_NAME_VERTX))))), Operator.ASSIGN)));
203
+ // initClientStatements.add(new ExpressionStmt(new MethodCallExpr(new NameExpr(FIELD_CLIENT_PROVIDER ), "provide ", new NodeList<>())));
204
+ initClientStatements .add (new ExpressionStmt (new AssignExpr (new VariableDeclarationExpr (vertxRequestAdapterType , "requestAdapter" ), new ObjectCreationExpr (null , vertxRequestAdapterType , new NodeList <>(new MethodCallExpr ( new NameExpr (FIELD_CLIENT_PROVIDER ), "provide" , new NodeList <>() ))), Operator .ASSIGN )));
209
205
initClientStatements .add (new ExpressionStmt (new MethodCallExpr (new NameExpr ("urlProvider" ), "provide" , new NodeList <>(new NameExpr ("requestAdapter" )))));
210
206
initClientStatements .add (new ExpressionStmt (new AssignExpr (new NameExpr (FIELD_API_CLIENT ), new ObjectCreationExpr (null , apiClientType , new NodeList <>(new NameExpr ("requestAdapter" ))), Operator .ASSIGN )));
211
207
initClientMethod .setBody (new BlockStmt (initClientStatements ));
@@ -214,7 +210,7 @@ private void initClientMethod(ClassOrInterfaceDeclaration clazz) {
214
210
private void fields (ClassOrInterfaceDeclaration clazz ) {
215
211
clazz .addField (Vertx .class , FIELD_NAME_VERTX ).addAnnotation (Inject .class );
216
212
clazz .addField ("ApiClient" , FIELD_API_CLIENT , Keyword .PRIVATE );
217
- clazz .addField ("HeaderAuthentication " , FIELD_AUTHENTICATION ).addAnnotation (Inject .class );
213
+ clazz .addField ("WebClientProvider " , FIELD_CLIENT_PROVIDER ).addAnnotation (Inject .class );
218
214
clazz .addField ("BaseUrlProvider" , "urlProvider" ).addAnnotation (Inject .class );
219
215
}
220
216
0 commit comments