public Builder mergeFrom(com.google.cloud.iot.v1.SendCommandToDeviceRequest other) { if (other == com.google.cloud.iot.v1.SendCommandToDeviceRequest.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { setBinaryData(other.getBinaryData()); } if (!other.getSubfolder().isEmpty()) { subfolder_ = other.subfolder_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.cloud.iot.v1.SendCommandToDeviceRequest buildPartial() { com.google.cloud.iot.v1.SendCommandToDeviceRequest result = new com.google.cloud.iot.v1.SendCommandToDeviceRequest(this); result.name_ = name_; result.binaryData_ = binaryData_; result.subfolder_ = subfolder_; onBuilt(); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.iot.v1.SendCommandToDeviceRequest)) { return super.equals(obj); } com.google.cloud.iot.v1.SendCommandToDeviceRequest other = (com.google.cloud.iot.v1.SendCommandToDeviceRequest) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getBinaryData().equals(other.getBinaryData()); result = result && getSubfolder().equals(other.getSubfolder()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; hash = (53 * hash) + getBinaryData().hashCode(); hash = (37 * hash) + SUBFOLDER_FIELD_NUMBER; hash = (53 * hash) + getSubfolder().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The command data to send to the device. * </pre> * * <code>bytes binary_data = 2;</code> */ public Builder clearBinaryData() { binaryData_ = getDefaultInstance().getBinaryData(); onChanged(); return this; }
/** * * * <pre> * The name of the device. For example, * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
/** * * * <pre> * Optional subfolder for the command. If empty, the command will be delivered * to the /devices/{device-id}/commands topic, otherwise it will be delivered * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level * subfolders are allowed. This field must not have more than 256 characters, * and must not contain any MQTT wildcards ("+" or "#") or null characters. * </pre> * * <code>string subfolder = 3;</code> */ public Builder clearSubfolder() { subfolder_ = getDefaultInstance().getSubfolder(); onChanged(); return this; } /**
@Override public Map<String, String> extract(SendCommandToDeviceRequest request) { ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put("name", String.valueOf(request.getName())); return params.build(); } })
@java.lang.Override public com.google.cloud.iot.v1.SendCommandToDeviceRequest getDefaultInstanceForType() { return com.google.cloud.iot.v1.SendCommandToDeviceRequest.getDefaultInstance(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } if (!binaryData_.isEmpty()) { output.writeBytes(2, binaryData_); } if (!getSubfolderBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, subfolder_); } unknownFields.writeTo(output); }
@Test @SuppressWarnings("all") public void sendCommandToDeviceTest() { SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.newBuilder().build(); mockDeviceManager.addResponse(expectedResponse); DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); ByteString binaryData = ByteString.copyFromUtf8("40"); String subfolder = "subfolder153561774"; SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(name, binaryData, subfolder); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockDeviceManager.getRequests(); Assert.assertEquals(1, actualRequests.size()); SendCommandToDeviceRequest actualRequest = (SendCommandToDeviceRequest) actualRequests.get(0); Assert.assertEquals(name, DeviceName.parse(actualRequest.getName())); Assert.assertEquals(binaryData, actualRequest.getBinaryData()); Assert.assertEquals(subfolder, actualRequest.getSubfolder()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; hash = (53 * hash) + getBinaryData().hashCode(); hash = (37 * hash) + SUBFOLDER_FIELD_NUMBER; hash = (53 * hash) + getSubfolder().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The name of the device. For example, * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
/** * * * <pre> * The command data to send to the device. * </pre> * * <code>bytes binary_data = 2;</code> */ public Builder clearBinaryData() { binaryData_ = getDefaultInstance().getBinaryData(); onChanged(); return this; }
/** * * * <pre> * Optional subfolder for the command. If empty, the command will be delivered * to the /devices/{device-id}/commands topic, otherwise it will be delivered * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level * subfolders are allowed. This field must not have more than 256 characters, * and must not contain any MQTT wildcards ("+" or "#") or null characters. * </pre> * * <code>string subfolder = 3;</code> */ public Builder clearSubfolder() { subfolder_ = getDefaultInstance().getSubfolder(); onChanged(); return this; } /**
io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.iot.v1.SendCommandToDeviceRequest .getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); } if (!binaryData_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, binaryData_); } if (!getSubfolderBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, subfolder_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
public Builder mergeFrom(com.google.cloud.iot.v1.SendCommandToDeviceRequest other) { if (other == com.google.cloud.iot.v1.SendCommandToDeviceRequest.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { setBinaryData(other.getBinaryData()); } if (!other.getSubfolder().isEmpty()) { subfolder_ = other.subfolder_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.iot.v1.SendCommandToDeviceRequest)) { return super.equals(obj); } com.google.cloud.iot.v1.SendCommandToDeviceRequest other = (com.google.cloud.iot.v1.SendCommandToDeviceRequest) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getBinaryData().equals(other.getBinaryData()); result = result && getSubfolder().equals(other.getSubfolder()); result = result && unknownFields.equals(other.unknownFields); return result; }