Skip to content

Commit c0a1269

Browse files
committed
Changes requested in code review.
1 parent dfd639f commit c0a1269

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterSetBuilder.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@
4444
public interface ParameterSetBuilder {
4545

4646
/**
47-
* Adds a parameter with a given name and value.
47+
* Adds a parameter with a given name and value. If the value is null, the
48+
* ParameterSet will behave as if no value has been set for the parameter.
49+
* Calling this method with a null value allows the ParameterSet to create
50+
* error messages that identify the {@code name} of missing parameters.
4851
*
4952
* @param <T> The type of value that is assigned to the parameter
50-
* @param name The parameter name
53+
* @param name The parameter name. Not null.
5154
* @param parameter The parameter that is assigned with the {@code name} and
52-
* {@code value} in this set
53-
* @param value The value
55+
* {@code value} in this set. Not null.
56+
* @param value The value, or null if the parameter is not configured with a
57+
* value.
5458
* @return A reference to this object
5559
*/
5660
<T> ParameterSetBuilder add(String name, Parameter<T> parameter, T value);

ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterSetParser.java

+5
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ <T> Builder addParameter(
189189
* the parsed input includes an assignment such as "x=0", then "0" is input
190190
* to the {@code valueSetter}.
191191
* </p><p>
192+
* The {@code valueSetter} must be able to handle a null input. A null input will occur
193+
* when no value is set for the parameter. The {@code valueSetter} may simply pass
194+
* the null value onto the {@code ParameterSetBuilder}, or it may pass in a default
195+
* value.
196+
* </p><p>
192197
* This method is designed for cases where a single parameter in text format
193198
* may map to multiple {@link Parameter} objects. The {@code valueSetter}
194199
* function can perform multiple calls to set each parameter, as in this

ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterSetParserImpl.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ public Builder addParameter(
129129
String name, Parameter<String> parameter, String defaultValue) {
130130
addParameterParser(
131131
name,
132-
(value, builder) -> builder.add(name, parameter, value));
132+
(value, builder) -> builder.add(name, parameter,
133+
value == null ? defaultValue : value));
133134
return this;
134135
}
135136

0 commit comments

Comments
 (0)