@@ -178,31 +178,56 @@ default float getFloat(String columnName) {
178
178
179
179
/**
180
180
* @param columnIndex index of the column
181
- * @return the value of a column with type T. return value(T) can be null.
181
+ * @return the value of a column with type T or null if the column contains a null value
182
+ * <p>Example
183
+ *
184
+ * <pre>{@code
185
+ * Struct row = ...
186
+ * String name = row.getOrNull(1, row::getString)
187
+ * }</pre>
182
188
*/
183
189
default <T > T getOrNull (int columnIndex , Function <Integer , T > function ) {
184
190
return isNull (columnIndex ) ? null : function .apply (columnIndex );
185
191
}
186
192
187
193
/**
188
194
* @param columnName index of the column
189
- * @return the value of a column with type T. return value(T) can be null.
195
+ * @return the value of a column with type T or null if the column contains a null value
196
+ * <p>Example
197
+ *
198
+ * <pre>{@code
199
+ * Struct row = ...
200
+ * String name = row.getOrNull("name", row::getString)
201
+ * }</pre>
190
202
*/
191
203
default <T > T getOrNull (String columnName , Function <String , T > function ) {
192
204
return isNull (columnName ) ? null : function .apply (columnName );
193
205
}
194
206
195
207
/**
196
208
* @param columnIndex index of the column
197
- * @return the value of a column with type T. if column value is null, returns default value.
209
+ * @return the value of a column with type T, or the given default if the column value is null
210
+ * <p>Example
211
+ *
212
+ * <pre>{@code
213
+ * Struct row = ...
214
+ * String name = row.getOrDefault(1, row::getString, "")
215
+ * }</pre>
198
216
*/
199
217
default <T > T getOrDefault (int columnIndex , Function <Integer , T > function , T defaultValue ) {
200
218
return isNull (columnIndex ) ? defaultValue : function .apply (columnIndex );
201
219
}
202
220
203
221
/**
204
222
* @param columnName name of the column
205
- * @return the value of a column with type T. if column value is null, returns default value.
223
+ * @return the value of a column with type T, or the given default if the column value is null
224
+ *
225
+ * <p>Example
226
+ *
227
+ * <pre>{@code
228
+ * Struct row = ...
229
+ * String name = row.getOrDefault("name", row::getString, "")
230
+ * }</pre>
206
231
*/
207
232
default <T > T getOrDefault (String columnName , Function <String , T > function , T defaultValue ) {
208
233
return isNull (columnName ) ? defaultValue : function .apply (columnName );
0 commit comments