|
19 | 19 | import com.google.cloud.spanner.ErrorCode; |
20 | 20 | import com.google.cloud.spanner.SpannerExceptionFactory; |
21 | 21 | import com.google.common.base.Strings; |
| 22 | +import com.google.common.collect.ImmutableList; |
22 | 23 | import java.util.Locale; |
23 | 24 | import javax.annotation.Nonnull; |
24 | 25 | import javax.annotation.Nullable; |
|
37 | 38 | * connection state is an opt-in. |
38 | 39 | */ |
39 | 40 | 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 | + |
40 | 45 | /** |
41 | 46 | * Context indicates when a {@link ConnectionProperty} may be set. Each higher-ordinal value |
42 | 47 | * includes the preceding values, meaning that a {@link ConnectionProperty} with {@link |
43 | 48 | * Context#USER} can be set both at connection startup and during the connection's lifetime. |
44 | 49 | */ |
45 | | - enum Context { |
| 50 | + public enum Context { |
46 | 51 | /** The property can only be set at startup of the connection. */ |
47 | 52 | STARTUP, |
48 | 53 | /** |
@@ -163,35 +168,38 @@ ConnectionPropertyValue<T> convert(@Nullable String stringValue) { |
163 | 168 | return new ConnectionPropertyValue<>(this, convertedValue, convertedValue); |
164 | 169 | } |
165 | 170 |
|
166 | | - String getKey() { |
| 171 | + @Nonnull |
| 172 | + public String getKey() { |
167 | 173 | return this.key; |
168 | 174 | } |
169 | 175 |
|
170 | | - boolean hasExtension() { |
| 176 | + public boolean hasExtension() { |
171 | 177 | return this.extension != null; |
172 | 178 | } |
173 | 179 |
|
174 | | - String getExtension() { |
| 180 | + public String getExtension() { |
175 | 181 | return this.extension; |
176 | 182 | } |
177 | 183 |
|
178 | | - String getName() { |
| 184 | + @Nonnull |
| 185 | + public String getName() { |
179 | 186 | return this.name; |
180 | 187 | } |
181 | 188 |
|
182 | | - String getDescription() { |
| 189 | + @Nonnull |
| 190 | + public String getDescription() { |
183 | 191 | return this.description; |
184 | 192 | } |
185 | 193 |
|
186 | | - T getDefaultValue() { |
| 194 | + public T getDefaultValue() { |
187 | 195 | return this.defaultValue; |
188 | 196 | } |
189 | 197 |
|
190 | | - T[] getValidValues() { |
| 198 | + public T[] getValidValues() { |
191 | 199 | return this.validValues; |
192 | 200 | } |
193 | 201 |
|
194 | | - Context getContext() { |
| 202 | + public Context getContext() { |
195 | 203 | return this.context; |
196 | 204 | } |
197 | 205 | } |
0 commit comments