|
20 | 20 | import static com.google.common.base.Preconditions.checkState; |
21 | 21 |
|
22 | 22 | import com.google.api.client.util.Data; |
| 23 | +import com.google.api.core.BetaApi; |
23 | 24 | import com.google.common.base.MoreObjects; |
24 | 25 | import com.google.common.io.BaseEncoding; |
25 | | - |
26 | 26 | import java.io.Serializable; |
27 | 27 | import java.util.List; |
28 | 28 | import java.util.Map; |
@@ -65,7 +65,7 @@ public enum Attribute { |
65 | 65 | } |
66 | 66 |
|
67 | 67 | private FieldValue(Attribute attribute, Object value) { |
68 | | - this.attribute = attribute; |
| 68 | + this.attribute = checkNotNull(attribute); |
69 | 69 | this.value = value; |
70 | 70 | } |
71 | 71 |
|
@@ -251,7 +251,22 @@ public final boolean equals(Object obj) { |
251 | 251 | return attribute == other.attribute && Objects.equals(value, other.value); |
252 | 252 | } |
253 | 253 |
|
254 | | - static FieldValue of(Attribute attribute, Object value) { |
| 254 | + /** |
| 255 | + * Creates an instance of {@code FieldValue}, useful for testing. |
| 256 | + * |
| 257 | + * <p>If the {@code attribute} is {@link Attribute#PRIMITIVE}, the {@code value} should be the |
| 258 | + * string representation of the underlying value, eg {@code "123"} for number {@code 123}. |
| 259 | + * |
| 260 | + * <p>If the {@code attribute} is {@link Attribute#REPEATED} or {@link Attribute#RECORD}, the |
| 261 | + * {@code value} should be {@code List} of {@link FieldValue}s or {@link FieldValueList}, |
| 262 | + * respectively. |
| 263 | + * |
| 264 | + * <p>This method is unstable. See <a |
| 265 | + * href="https://github.com/GoogleCloudPlatform/google-cloud-java/pull/2891">this discussion</a> |
| 266 | + * for more context. |
| 267 | + */ |
| 268 | + @BetaApi |
| 269 | + public static FieldValue of(Attribute attribute, Object value) { |
255 | 270 | return new FieldValue(attribute, value); |
256 | 271 | } |
257 | 272 |
|
|
0 commit comments