Skip to content

Commit

Permalink
fix: add javadoc comments for configurable properties
Browse files Browse the repository at this point in the history
  • Loading branch information
emmileaf committed Dec 19, 2022
1 parent 4d55a7a commit 6d6d01e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,19 @@ private static List<Statement> createMemberVariables(
true,
defaultCredentialScopes,
nestedPropertyAnnotations);
statements.add(SpringPropertiesCommentComposer.createCredentialsPropertyComment());
statements.add(credentialsStatement);
// private String quotaProjectId;
ExprStatement quotaProjectIdVarStatement =
ComposerUtils.createMemberVarStatement(
"quotaProjectId", TypeNode.STRING, false, null, null);
statements.add(SpringPropertiesCommentComposer.createQuotaProjectIdPropertyComment());
statements.add(quotaProjectIdVarStatement);
// private Integer executorThreadCount;
ExprStatement executorThreadCountVarStatement =
ComposerUtils.createMemberVarStatement(
"executorThreadCount", TypeNode.INT_OBJECT, false, null, null);
statements.add(SpringPropertiesCommentComposer.createExecutorThreadCountPropertyComment());
statements.add(executorThreadCountVarStatement);
if (hasRestOption) {
ExprStatement useRestVarStatement =
Expand All @@ -158,6 +161,7 @@ private static List<Statement> createMemberVariables(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("false").build()),
null);
statements.add(SpringPropertiesCommentComposer.createUseRestPropertyComment());
statements.add(useRestVarStatement);
}
// private Retry retrySettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
public class SpringPropertiesCommentComposer {
private static final String CLASS_HEADER_GENERAL_DESCRIPTION =
"Provides default property values for %s client bean";
private static final String CREDENTIALS_DESCRIPTION =
"OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries.";
private static final String QUOTA_PROJECT_ID_DESCRIPTION = "Quota project to use for billing.";
private static final String EXECUTOR_THREAD_COUNT_DESCRIPTION =
"Number of threads used for executors.";
private static final String USE_REST_DESCRIPTION =
"Allow override of default transport channel provider to use REST instead of gRPC.";

public static List<CommentStatement> createClassHeaderComments(
String configuredClassName, String serviceName) {
Expand All @@ -34,4 +41,24 @@ public static List<CommentStatement> createClassHeaderComments(
CommentComposer.AUTO_GENERATED_CLASS_COMMENT,
CommentStatement.withComment(javaDocCommentBuilder.build()));
}

public static CommentStatement createCredentialsPropertyComment() {
return toSimpleJavaDocComment(CREDENTIALS_DESCRIPTION);
}

public static CommentStatement createQuotaProjectIdPropertyComment() {
return toSimpleJavaDocComment(QUOTA_PROJECT_ID_DESCRIPTION);
}

public static CommentStatement createExecutorThreadCountPropertyComment() {
return toSimpleJavaDocComment(EXECUTOR_THREAD_COUNT_DESCRIPTION);
}

public static CommentStatement createUseRestPropertyComment() {
return toSimpleJavaDocComment(USE_REST_DESCRIPTION);
}

private static CommentStatement toSimpleJavaDocComment(String comment) {
return CommentStatement.withComment(JavaDocComment.withComment(comment));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
@BetaApi("Autogenerated Spring autoconfiguration is not yet stable")
@ConfigurationProperties("com.google.showcase.v1beta1.spring.auto.echo")
public class EchoSpringProperties implements CredentialsSupplier {
/** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */
@NestedConfigurationProperty
private final Credentials credentials =
new Credentials("https://www.googleapis.com/auth/cloud-platform");

/** Quota project to use for billing. */
private String quotaProjectId;
/** Number of threads used for executors. */
private Integer executorThreadCount;

@NestedConfigurationProperty private Retry retrySettings;
@NestedConfigurationProperty private Retry echoRetrySettings;
@NestedConfigurationProperty private Retry expandRetrySettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
/** Provides default property values for Echo client bean */
@ConfigurationProperties("com.google.showcase.v1beta1.spring.auto.echo")
public class EchoSpringProperties implements CredentialsSupplier {
/** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */
@NestedConfigurationProperty
private final Credentials credentials =
new Credentials("https://www.googleapis.com/auth/cloud-platform");

/** Quota project to use for billing. */
private String quotaProjectId;
/** Number of threads used for executors. */
private Integer executorThreadCount;

@NestedConfigurationProperty private Retry retrySettings;
@NestedConfigurationProperty private Retry echoRetrySettings;
@NestedConfigurationProperty private Retry expandRetrySettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
/** Provides default property values for Echo client bean */
@ConfigurationProperties("com.google.showcase.v1beta1.spring.auto.echo")
public class EchoSpringProperties implements CredentialsSupplier {
/** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */
@NestedConfigurationProperty
private final Credentials credentials =
new Credentials("https://www.googleapis.com/auth/cloud-platform");

/** Quota project to use for billing. */
private String quotaProjectId;
/** Number of threads used for executors. */
private Integer executorThreadCount;
/** Allow override of default transport channel provider to use REST instead of gRPC. */
private boolean useRest = false;

@NestedConfigurationProperty private Retry retrySettings;
@NestedConfigurationProperty private Retry echoRetrySettings;
@NestedConfigurationProperty private Retry expandRetrySettings;
Expand Down

0 comments on commit 6d6d01e

Please sign in to comment.