-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spring): use shared configuration (#1071)
* fix(spring codegen): use client-library-artifact-id as pom artifactId prefix. (#1092) * rename to global properties * fix(test): update goldens * fix: format * fix: typo in GLobalProperties * fix: typo in goldens * fix: remove unnecessary comments * fix: reference to com.google.cloud.spring.global * fix: typo and static ref fix Co-authored-by: Min Zhu <[email protected]>
- Loading branch information
1 parent
8625e7c
commit 8755403
Showing
5 changed files
with
213 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/google/api/generator/spring/utils/GlobalPropertiesUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.api.generator.spring.utils; | ||
|
||
import com.google.api.generator.engine.ast.ExprStatement; | ||
import com.google.api.generator.engine.ast.ScopeNode; | ||
import com.google.api.generator.engine.ast.Statement; | ||
import com.google.api.generator.engine.ast.TypeNode; | ||
import com.google.api.generator.engine.ast.VaporReference; | ||
import com.google.api.generator.engine.ast.Variable; | ||
import com.google.api.generator.engine.ast.VariableExpr; | ||
import java.util.Map; | ||
|
||
public class GlobalPropertiesUtils { | ||
public static final String GLOBAL_PROPERTIES_CLAZZ_NAME = "GlobalProperties"; | ||
public static final String GLOBAL_PROPERTIES_PAKKAGE_NAME = "com.google.cloud.spring.global"; | ||
|
||
public static TypeNode getGlobalPropertiesType() { | ||
TypeNode loggerType = | ||
TypeNode.withReference( | ||
VaporReference.builder() | ||
.setName(GLOBAL_PROPERTIES_CLAZZ_NAME) | ||
.setPakkage(GLOBAL_PROPERTIES_PAKKAGE_NAME) | ||
.build()); | ||
return loggerType; | ||
} | ||
|
||
public static Statement getGlobalPropertiesDeclaration(Map<String, TypeNode> types) { | ||
Variable globalPropertiesVar = | ||
Variable.builder() | ||
.setName("globalProperties") | ||
.setType(types.get("GlobalProperties")) | ||
.build(); | ||
return ExprStatement.withExpr( | ||
VariableExpr.builder() | ||
.setVariable(globalPropertiesVar) | ||
.setScope(ScopeNode.PRIVATE) | ||
.setIsStatic(false) | ||
.setIsFinal(true) | ||
.setIsDecl(true) | ||
.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.