Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bson/src/main/org/bson/BinaryVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
* @since 5.3
*/
public abstract class BinaryVector {
/**
* The BinaryVector logger
*/
protected static final Logger LOGGER = Loggers.getLogger("BinaryVector");
private final DataType dataType;

Expand Down
16 changes: 14 additions & 2 deletions bson/src/main/org/bson/BsonBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ public BsonBinary(final UUID uuid, final UuidRepresentation uuidRepresentation)
}

/**
* Returns the binary as a UUID. The binary type must be 4.
* Returns the binary as a UUID.
*
* <p><strong>Note:</strong>The BsonBinary subtype must be {@link BsonBinarySubType#UUID_STANDARD}.</p>
*
* @return the uuid
* @throws BsonInvalidOperationException if BsonBinary subtype is not {@link BsonBinarySubType#UUID_STANDARD}
* @see #asUuid(UuidRepresentation)
* @see BsonBinarySubType
* @since 3.9
*/
public UUID asUuid() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change the method signature to reflect the throws documentation ?
UUID asUuid() throws BsonInvalidOperationException

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a good point, however, it would introduce a new convention. For runtime errors we generally don't use checked exception patterns in the driver.

Expand Down Expand Up @@ -162,8 +167,15 @@ public BinaryVector asVector() {
/**
* Returns the binary as a UUID.
*
* @param uuidRepresentation the UUID representation
* <p><strong>Note:</strong>The BsonBinary subtype must be either {@link BsonBinarySubType#UUID_STANDARD} or
* {@link BsonBinarySubType#UUID_LEGACY}.</p>
*
* @param uuidRepresentation the UUID representation, must be {@link UuidRepresentation#STANDARD} or
* {@link UuidRepresentation#JAVA_LEGACY}
* @return the uuid
* @throws BsonInvalidOperationException if the BsonBinary subtype is incompatible with the given {@code uuidRepresentation}, or if
* the {@code uuidRepresentation} is not {@link UuidRepresentation#STANDARD} or
* {@link UuidRepresentation#JAVA_LEGACY}.
* @since 3.9
*/
public UUID asUuid(final UuidRepresentation uuidRepresentation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here should we add throws to method signature ?
https://github.com/mongodb/mongo-java-driver/pull/1883/changes#r2783802952

Expand Down
2 changes: 1 addition & 1 deletion bson/src/main/org/bson/BsonBinarySubType.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public enum BsonBinarySubType {
* Returns true if the given value is a UUID subtype.
*
* @param value the subtype value as a byte.
* @return true if value is a UUID subtype.
* @return true if value has a {@link #UUID_STANDARD} or {@link #UUID_LEGACY} subtype.
* @since 3.4
*/
public static boolean isUuid(final byte value) {
Expand Down