This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathConnectionPropertiesFileGenerator.java
More file actions
73 lines (68 loc) · 2.97 KB
/
Copy pathConnectionPropertiesFileGenerator.java
File metadata and controls
73 lines (68 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright 2024 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.cloud.spanner.jdbc;
import com.google.cloud.spanner.connection.ConnectionProperty;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
/** Generator for the documentation/connection_properties.md file. */
public class ConnectionPropertiesFileGenerator {
public static void main(String[] args) throws IOException {
StringBuilder builder =
new StringBuilder("# Supported Connection Properties\n\n")
.append(
"This file contains all supported connection properties for the Spanner JDBC driver. "
+ "These properties can be specified both in the connection URL and in the Properties map "
+ "that is used to create a connection.\n\n"
+ "The 'Context' value indicates whether the property can only be set when a connection is "
+ "created (STARTUP), or whether the value can also be changed after a connection has been "
+ "created.\n\n");
builder.append("| Name | Description | Default | Enum values | Context |\n");
builder.append("|------|-------------|---------|-------------|---------|\n");
for (ConnectionProperty<?> connectionProperty :
ConnectionPropertiesHelper.VALID_CONNECTION_PROPERTIES) {
builder
.append("| ")
.append(connectionProperty.getName())
.append(" | ")
.append(connectionProperty.getDescription().replace("\n", " "))
.append(" | ")
.append(
connectionProperty.getDefaultValue() == null
? ""
: connectionProperty.getDefaultValue().toString())
.append(" | ")
.append(getValidValues(connectionProperty))
.append(" | ")
.append(connectionProperty.getContext())
.append(" |\n");
}
try (BufferedWriter writer =
new BufferedWriter(new FileWriter("documentation/connection_properties.md"))) {
writer.write(builder.toString());
}
}
static <T> String getValidValues(ConnectionProperty<T> connectionProperty) {
return connectionProperty.getValidValues() == null
? ""
: Arrays.stream(connectionProperty.getValidValues())
.map(Objects::toString)
.collect(Collectors.joining(", "));
}
}