Skip to content

Commit 43eb31b

Browse files
committed
Fix javadoc error, add checkNotNull to FieldValue getters
1 parent 50d381f commit 43eb31b

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/FieldValue.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
/**
3333
* Google BigQuery Table Field Value class. Objects of this class represent values of a BigQuery
34-
* Table Field. A list of values forms a {@link TableRow}. Tables rows can be gotten as the result
35-
* of a query or when listing table data.
34+
* Table Field. A list of values forms a table row. Tables rows can be gotten as the result of a
35+
* query or when listing table data.
3636
*/
3737
public class FieldValue implements Serializable {
3838

@@ -99,7 +99,8 @@ public boolean isNull() {
9999
}
100100

101101
/**
102-
* Returns this field's value as an {@link Object}.
102+
* Returns this field's value as a {@link Object}. If {@link #isNull()} is {@code true} this
103+
* method returns {@code null}.
103104
*/
104105
public Object value() {
105106
return value;
@@ -112,9 +113,11 @@ public Object value() {
112113
* {@link Field.Type#timestamp()}).
113114
*
114115
* @throws ClassCastException if the field is not a primitive type
116+
* @throws NullPointerException if {@link #isNull()} returns {@code true}
115117
*/
116118
@SuppressWarnings("unchecked")
117119
public String stringValue() {
120+
checkNotNull(value);
118121
return (String) value;
119122
}
120123

@@ -155,7 +158,6 @@ public double doubleValue() {
155158
@SuppressWarnings("unchecked")
156159
public boolean booleanValue() {
157160
String stringValue = stringValue();
158-
checkNotNull(stringValue);
159161
checkState(stringValue.equalsIgnoreCase("true") || stringValue.equalsIgnoreCase("false"),
160162
"Field value is not of boolean type");
161163
return Boolean.parseBoolean(stringValue);
@@ -183,9 +185,11 @@ public long timestampValue() {
183185
* {@link Attribute#REPEATED}).
184186
*
185187
* @throws ClassCastException if the field has not {@link Field.Mode#REPEATED} mode
188+
* @throws NullPointerException if {@link #isNull()} returns {@code true}
186189
*/
187190
@SuppressWarnings("unchecked")
188191
public List<FieldValue> repeatedValue() {
192+
checkNotNull(value);
189193
return (List<FieldValue>) value;
190194
}
191195

@@ -195,9 +199,11 @@ public List<FieldValue> repeatedValue() {
195199
* is {@link Attribute#RECORD}).
196200
*
197201
* @throws ClassCastException if the field is not a {@link Field.Type#record(Field...)} type
202+
* @throws NullPointerException if {@link #isNull()} returns {@code true}
198203
*/
199204
@SuppressWarnings("unchecked")
200205
public List<FieldValue> recordValue() {
206+
checkNotNull(value);
201207
return (List<FieldValue>) value;
202208
}
203209

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public class InsertAllRequest implements Serializable {
5050
* A Google Big Query row to be inserted into a table. Each {@code RowToInsert} has an associated
5151
* id used by BigQuery to detect duplicate insertion requests on a best-effort basis.
5252
*
53-
* <p>
54-
* Example usage of creating a row to insert:
53+
* <p>Example usage of creating a row to insert:
5554
* <pre> {@code
5655
* List<Long> repeatedFieldValue = Arrays.asList(1L, 2L);
5756
* Map<String, Object> recordContent = new HashMap<String, Object>();
@@ -128,7 +127,6 @@ public static RowToInsert of(String id, Map<String, Object> content) {
128127
/**
129128
* Creates a row to be inserted without associated id.
130129
*
131-
* @param id id of the row, used to identify duplicates
132130
* @param content the actual content of the row
133131
*/
134132
public static RowToInsert of(Map<String, Object> content) {
@@ -176,8 +174,7 @@ public Builder addRow(RowToInsert rowToInsert) {
176174
/**
177175
* Adds a row to be inserted with associated id.
178176
*
179-
* <p>
180-
* Example usage of adding a row with associated id:
177+
* <p>Example usage of adding a row with associated id:
181178
* <pre> {@code
182179
* InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
183180
* List<Long> repeatedFieldValue = Arrays.asList(1L, 2L);
@@ -198,8 +195,7 @@ public Builder addRow(String id, Map<String, Object> content) {
198195
/**
199196
* Adds a row to be inserted without an associated id.
200197
*
201-
* <p>
202-
* Example usage of adding a row without an associated id:
198+
* <p>Example usage of adding a row without an associated id:
203199
* <pre> {@code
204200
* InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
205201
* List<Long> repeatedFieldValue = Arrays.asList(1L, 2L);

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/**
3636
* Google Cloud BigQuery insert all response. Objects of this class possibly contain errors for an
3737
* {@link InsertAllRequest}. If a row failed to be inserted, the non-empty list of errors associated
38-
* to that row's index can be obtained with {@link InsertAllResponse#errorsFor(Long)}.
38+
* to that row's index can be obtained with {@link InsertAllResponse#errorsFor(long)}.
3939
* {@link InsertAllResponse#insertErrors()} can be used to return all errors caused by a
4040
* {@link InsertAllRequest} as a map.
4141
*/

0 commit comments

Comments
 (0)