/** * * * <pre> * The language of the text, which will be the same as the language specified * in the request or, if not specified, the automatically-detected language. * See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. * </pre> * * <code>string language = 2;</code> */ public Builder clearLanguage() { language_ = getDefaultInstance().getLanguage(); onChanged(); return this; } /**
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasDocumentSentiment()) { hash = (37 * hash) + DOCUMENT_SENTIMENT_FIELD_NUMBER; hash = (53 * hash) + getDocumentSentiment().hashCode(); } hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; hash = (53 * hash) + getLanguage().hashCode(); if (getSentencesCount() > 0) { hash = (37 * hash) + SENTENCES_FIELD_NUMBER; hash = (53 * hash) + getSentencesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1beta2.AnalyzeSentimentResponse)) { return super.equals(obj); } com.google.cloud.language.v1beta2.AnalyzeSentimentResponse other = (com.google.cloud.language.v1beta2.AnalyzeSentimentResponse) obj; boolean result = true; result = result && (hasDocumentSentiment() == other.hasDocumentSentiment()); if (hasDocumentSentiment()) { result = result && getDocumentSentiment().equals(other.getDocumentSentiment()); } result = result && getLanguage().equals(other.getLanguage()); result = result && getSentencesList().equals(other.getSentencesList()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (documentSentiment_ != null) { output.writeMessage(1, getDocumentSentiment()); } if (!getLanguageBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, language_); } for (int i = 0; i < sentences_.size(); i++) { output.writeMessage(3, sentences_.get(i)); } unknownFields.writeTo(output); }
public Builder mergeFrom(com.google.cloud.language.v1beta2.AnalyzeSentimentResponse other) { if (other == com.google.cloud.language.v1beta2.AnalyzeSentimentResponse.getDefaultInstance()) return this; if (other.hasDocumentSentiment()) { mergeDocumentSentiment(other.getDocumentSentiment()); if (!other.getLanguage().isEmpty()) { language_ = other.language_; onChanged();
/** * * * <pre> * The overall sentiment of the input document. * </pre> * * <code>.google.cloud.language.v1beta2.Sentiment document_sentiment = 1;</code> */ public com.google.cloud.language.v1beta2.SentimentOrBuilder getDocumentSentimentOrBuilder() { return getDocumentSentiment(); }
@java.lang.Override public com.google.cloud.language.v1beta2.AnalyzeSentimentResponse getDefaultInstanceForType() { return com.google.cloud.language.v1beta2.AnalyzeSentimentResponse.getDefaultInstance(); }
@java.lang.Override public com.google.cloud.language.v1beta2.AnalyzeSentimentResponse buildPartial() { com.google.cloud.language.v1beta2.AnalyzeSentimentResponse result = new com.google.cloud.language.v1beta2.AnalyzeSentimentResponse(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (documentSentimentBuilder_ == null) { result.documentSentiment_ = documentSentiment_; } else { result.documentSentiment_ = documentSentimentBuilder_.build(); } result.language_ = language_; if (sentencesBuilder_ == null) { if (((bitField0_ & 0x00000004) == 0x00000004)) { sentences_ = java.util.Collections.unmodifiableList(sentences_); bitField0_ = (bitField0_ & ~0x00000004); } result.sentences_ = sentences_; } else { result.sentences_ = sentencesBuilder_.build(); } result.bitField0_ = to_bitField0_; onBuilt(); return result; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (documentSentiment_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDocumentSentiment()); } if (!getLanguageBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, language_); } for (int i = 0; i < sentences_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, sentences_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
Sentiment sentiment = response.getDocumentSentiment(); if (sentiment != null) { System.out.println("Found sentiment.");
io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.language.v1beta2.AnalyzeSentimentResponse .getDefaultInstance())) .setSchemaDescriptor( new LanguageServiceMethodDescriptorSupplier("AnalyzeSentiment"))
@Test @SuppressWarnings("all") public void analyzeSentimentTest() { String language = "language-1613589672"; AnalyzeSentimentResponse expectedResponse = AnalyzeSentimentResponse.newBuilder().setLanguage(language).build(); mockLanguageService.addResponse(expectedResponse); Document document = Document.newBuilder().build(); AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests(); Assert.assertEquals(1, actualRequests.size()); AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0); Assert.assertEquals(document, actualRequest.getDocument()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }