Skip to content

Commit 742cddd

Browse files
committed
chore: make valid connection properties public
Make the list of valid connection properties public, so tools that depend on the Connection API can use this to for example generate documentation for valid properties.
1 parent 8547735 commit 742cddd

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionProperties.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
import com.google.common.collect.ImmutableMap;
116116
import com.google.spanner.v1.DirectedReadOptions;
117117
import java.time.Duration;
118-
import java.util.Map;
119118

120119
/**
121120
* Utility class that defines all known connection properties. This class will eventually replace
@@ -541,7 +540,7 @@ class ConnectionProperties {
541540
BooleanConverter.INSTANCE,
542541
Context.USER);
543542

544-
static final Map<String, ConnectionProperty<?>> CONNECTION_PROPERTIES =
543+
static final ImmutableMap<String, ConnectionProperty<?>> CONNECTION_PROPERTIES =
545544
CONNECTION_PROPERTIES_BUILDER.build();
546545

547546
/** Utility method for creating a new core {@link ConnectionProperty}. */

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionProperty.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.cloud.spanner.ErrorCode;
2020
import com.google.cloud.spanner.SpannerExceptionFactory;
2121
import com.google.common.base.Strings;
22+
import com.google.common.collect.ImmutableList;
2223
import java.util.Locale;
2324
import javax.annotation.Nonnull;
2425
import javax.annotation.Nullable;
@@ -37,12 +38,16 @@
3738
* connection state is an opt-in.
3839
*/
3940
public class ConnectionProperty<T> {
41+
/** The list of all supported connection properties. */
42+
public static ImmutableList<ConnectionProperty<?>> VALID_CONNECTION_PROPERTIES =
43+
ImmutableList.copyOf(ConnectionProperties.CONNECTION_PROPERTIES.values());
44+
4045
/**
4146
* Context indicates when a {@link ConnectionProperty} may be set. Each higher-ordinal value
4247
* includes the preceding values, meaning that a {@link ConnectionProperty} with {@link
4348
* Context#USER} can be set both at connection startup and during the connection's lifetime.
4449
*/
45-
enum Context {
50+
public enum Context {
4651
/** The property can only be set at startup of the connection. */
4752
STARTUP,
4853
/**
@@ -163,35 +168,38 @@ ConnectionPropertyValue<T> convert(@Nullable String stringValue) {
163168
return new ConnectionPropertyValue<>(this, convertedValue, convertedValue);
164169
}
165170

166-
String getKey() {
171+
@Nonnull
172+
public String getKey() {
167173
return this.key;
168174
}
169175

170-
boolean hasExtension() {
176+
public boolean hasExtension() {
171177
return this.extension != null;
172178
}
173179

174-
String getExtension() {
180+
public String getExtension() {
175181
return this.extension;
176182
}
177183

178-
String getName() {
184+
@Nonnull
185+
public String getName() {
179186
return this.name;
180187
}
181188

182-
String getDescription() {
189+
@Nonnull
190+
public String getDescription() {
183191
return this.description;
184192
}
185193

186-
T getDefaultValue() {
194+
public T getDefaultValue() {
187195
return this.defaultValue;
188196
}
189197

190-
T[] getValidValues() {
198+
public T[] getValidValues() {
191199
return this.validValues;
192200
}
193201

194-
Context getContext() {
202+
public Context getContext() {
195203
return this.context;
196204
}
197205
}

0 commit comments

Comments
 (0)