Skip to content

Commit

Permalink
Make deviceName @NotNull and make sure it is never null
Browse files Browse the repository at this point in the history
  • Loading branch information
weliem committed Mar 5, 2021
1 parent ee00c4d commit bcd44ef
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class BluetoothPeripheral {
@Nullable
private BluezDevice device;

@Nullable
@NotNull
private String deviceName;

@NotNull
Expand Down Expand Up @@ -296,7 +296,7 @@ private void completeDisconnect(final boolean notify, @NotNull final BluetoothCo
public BluetoothPeripheral(@NotNull final BluetoothCentralManager central, @Nullable final BluezDevice bluezDevice, @Nullable final String deviceName, @NotNull final String deviceAddress, @NotNull final InternalCallback listener, @Nullable final BluetoothPeripheralCallback peripheralCallback, @NotNull final Handler callBackHandler) {
this.central = Objects.requireNonNull(central, "no valid central provided");
this.device = bluezDevice;
this.deviceName = deviceName;
this.deviceName = deviceName == null ? "" : deviceName;
this.deviceAddress = Objects.requireNonNull(deviceAddress, "no valid address provided");
this.listener = Objects.requireNonNull(listener, "no valid listener provided");
if (peripheralCallback != null) {
Expand Down Expand Up @@ -970,13 +970,13 @@ public BluetoothGattCharacteristic getCharacteristic(@NotNull final UUID service
*
* @return name of the bluetooth peripheral
*/
@Nullable
@NotNull
public String getName() {
return deviceName;
}

void setName(@Nullable final String name) {
deviceName = name;
deviceName = name == null ? "" : name;
}

/**
Expand Down

0 comments on commit bcd44ef

Please sign in to comment.