Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 39e1005

Browse files
authored
[Fix] Minor improvements to new type definitions. (#2)
1 parent 74d4877 commit 39e1005

8 files changed

Lines changed: 16 additions & 21 deletions

File tree

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BsonBinaryData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public class BsonBinaryData implements Serializable {
2727
private static final long serialVersionUID = 1830984831902814656L;
2828
private final int subtype;
29-
private final ByteString data;
29+
@Nonnull private final ByteString data;
3030

3131
private BsonBinaryData(int subtype, @Nonnull ByteString data) {
3232
// By definition the subtype should be 1 byte and should therefore
@@ -108,7 +108,7 @@ public boolean equals(Object obj) {
108108
return false;
109109
}
110110
BsonBinaryData other = (BsonBinaryData) obj;
111-
return Objects.equals(this.subtype, other.subtype) && Objects.equals(this.data, other.data);
111+
return this.subtype == other.subtype && Objects.equals(this.data, other.data);
112112
}
113113

114114
@Override
@@ -119,7 +119,7 @@ public int hashCode() {
119119
@Nonnull
120120
@Override
121121
public String toString() {
122-
return "BsonBinaryData { subtype=" + this.subtype + ", data=" + this.data.toString() + " }";
122+
return "BsonBinaryData{subtype=" + this.subtype + ", data=" + this.data.toString() + " }";
123123
}
124124

125125
MapValue toProto() {

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BsonObjectId.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/** Represents a BSON ObjectId type in Firestore documents. */
2525
public class BsonObjectId implements Serializable {
2626
private static final long serialVersionUID = 430753173775328933L;
27-
public final String value;
27+
@Nonnull public final String value;
2828

2929
/**
3030
* Constructor that creates a new BSON ObjectId value with the given value.
@@ -65,6 +65,6 @@ public int hashCode() {
6565
@Nonnull
6666
@Override
6767
public String toString() {
68-
return "BsonObjectId { value=" + this.value + " }";
68+
return "BsonObjectId{value=" + this.value + "}";
6969
}
7070
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/BsonTimestamp.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public boolean equals(Object obj) {
6565
return false;
6666
}
6767
BsonTimestamp other = (BsonTimestamp) obj;
68-
return Objects.equals(this.seconds, other.seconds)
69-
&& Objects.equals(this.increment, other.increment);
68+
return this.seconds == other.seconds && this.increment == other.increment;
7069
}
7170

7271
@Override
@@ -77,6 +76,6 @@ public int hashCode() {
7776
@Nonnull
7877
@Override
7978
public String toString() {
80-
return "BsonTimestamp { seconds=" + this.seconds + ", increment=" + this.increment + " }";
79+
return "BsonTimestamp{seconds=" + this.seconds + ", increment=" + this.increment + "}";
8180
}
8281
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public static MaxKey maxKey() {
359359
* @return A new {@link RegexValue} constructed using the given pattern and options.
360360
*/
361361
@Nonnull
362-
public static RegexValue regex(String pattern, String options) {
362+
public static RegexValue regex(@Nonnull String pattern, @Nonnull String options) {
363363
return new RegexValue(pattern, options);
364364
}
365365

@@ -393,7 +393,7 @@ public static BsonTimestamp bsonTimestamp(long seconds, long increment) {
393393
* @return A new {@link BsonObjectId} constructed using the given value.
394394
*/
395395
@Nonnull
396-
public static BsonObjectId bsonObjectId(String oid) {
396+
public static BsonObjectId bsonObjectId(@Nonnull String oid) {
397397
return new BsonObjectId(oid);
398398
}
399399

google-cloud-firestore/src/main/java/com/google/cloud/firestore/Int32Value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public int hashCode() {
5656
@Nonnull
5757
@Override
5858
public String toString() {
59-
return "Int32Value { value=" + this.value + " }";
59+
return "Int32Value{value=" + this.value + "}";
6060
}
6161
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/MaxKey.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class MaxKey implements Serializable {
2828

2929
private MaxKey() {}
3030

31+
@Nonnull
3132
public static MaxKey instance() {
3233
return INSTANCE;
3334
}
@@ -44,10 +45,7 @@ MapValue toProto() {
4445
*/
4546
@Override
4647
public boolean equals(Object obj) {
47-
if (this == obj) {
48-
return true;
49-
}
50-
return obj != null && getClass() == obj.getClass();
48+
return this == obj;
5149
}
5250

5351
@Override

google-cloud-firestore/src/main/java/com/google/cloud/firestore/MinKey.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class MinKey implements Serializable {
2828

2929
private MinKey() {}
3030

31+
@Nonnull
3132
public static MinKey instance() {
3233
return INSTANCE;
3334
}
@@ -44,10 +45,7 @@ MapValue toProto() {
4445
*/
4546
@Override
4647
public boolean equals(Object obj) {
47-
if (this == obj) {
48-
return true;
49-
}
50-
return obj != null && getClass() == obj.getClass();
48+
return this == obj;
5149
}
5250

5351
@Override

google-cloud-firestore/src/main/java/com/google/cloud/firestore/RegexValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class RegexValue implements Serializable {
2828
public final String pattern;
2929
public final String options;
3030

31-
public RegexValue(String pattern, String options) {
31+
public RegexValue(@Nonnull String pattern, @Nonnull String options) {
3232
this.pattern = pattern;
3333
this.options = options;
3434
}
@@ -63,6 +63,6 @@ public int hashCode() {
6363
@Nonnull
6464
@Override
6565
public String toString() {
66-
return "RegexValue { pattern=" + this.pattern + ", options=" + this.options + " }";
66+
return "RegexValue{pattern=" + this.pattern + ", options=" + this.options + "}";
6767
}
6868
}

0 commit comments

Comments
 (0)