/** * * * <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 = 5;</code> */ public Builder clearLanguage() { language_ = getDefaultInstance().getLanguage(); onChanged(); return this; } /**
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
hash = (19 * hash) + getDescriptor().hashCode(); if (getSentencesCount() > 0) { hash = (37 * hash) + SENTENCES_FIELD_NUMBER; hash = (53 * hash) + getSentencesList().hashCode(); if (getTokensCount() > 0) { hash = (37 * hash) + TOKENS_FIELD_NUMBER; hash = (53 * hash) + getTokensList().hashCode(); if (getEntitiesCount() > 0) { hash = (37 * hash) + ENTITIES_FIELD_NUMBER; hash = (53 * hash) + getEntitiesList().hashCode(); if (hasDocumentSentiment()) { hash = (37 * hash) + DOCUMENT_SENTIMENT_FIELD_NUMBER; hash = (53 * hash) + getDocumentSentiment().hashCode(); hash = (53 * hash) + getLanguage().hashCode(); if (getCategoriesCount() > 0) { hash = (37 * hash) + CATEGORIES_FIELD_NUMBER; hash = (53 * hash) + getCategoriesList().hashCode();
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.language.v1beta2.AnnotateTextResponse)) { return super.equals(obj); } com.google.cloud.language.v1beta2.AnnotateTextResponse other = (com.google.cloud.language.v1beta2.AnnotateTextResponse) obj; boolean result = true; result = result && getSentencesList().equals(other.getSentencesList()); result = result && getTokensList().equals(other.getTokensList()); result = result && getEntitiesList().equals(other.getEntitiesList()); result = result && (hasDocumentSentiment() == other.hasDocumentSentiment()); if (hasDocumentSentiment()) { result = result && getDocumentSentiment().equals(other.getDocumentSentiment()); } result = result && getLanguage().equals(other.getLanguage()); result = result && getCategoriesList().equals(other.getCategoriesList()); result = result && unknownFields.equals(other.unknownFields); return result; }
public Builder mergeFrom(com.google.cloud.language.v1beta2.AnnotateTextResponse other) { if (other == com.google.cloud.language.v1beta2.AnnotateTextResponse.getDefaultInstance()) return this; if (sentencesBuilder_ == null) { if (other.hasDocumentSentiment()) { mergeDocumentSentiment(other.getDocumentSentiment()); if (!other.getLanguage().isEmpty()) { language_ = other.language_; onChanged();
@java.lang.Override public com.google.cloud.language.v1beta2.AnnotateTextResponse getDefaultInstanceForType() { return com.google.cloud.language.v1beta2.AnnotateTextResponse.getDefaultInstance(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { for (int i = 0; i < sentences_.size(); i++) { output.writeMessage(1, sentences_.get(i)); } for (int i = 0; i < tokens_.size(); i++) { output.writeMessage(2, tokens_.get(i)); } for (int i = 0; i < entities_.size(); i++) { output.writeMessage(3, entities_.get(i)); } if (documentSentiment_ != null) { output.writeMessage(4, getDocumentSentiment()); } if (!getLanguageBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 5, language_); } for (int i = 0; i < categories_.size(); i++) { output.writeMessage(6, categories_.get(i)); } unknownFields.writeTo(output); }
/** * * * <pre> * The overall sentiment for the document. Populated if the user enables * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. * </pre> * * <code>.google.cloud.language.v1beta2.Sentiment document_sentiment = 4;</code> */ public com.google.cloud.language.v1beta2.SentimentOrBuilder getDocumentSentimentOrBuilder() { return getDocumentSentiment(); }
@java.lang.Override public com.google.cloud.language.v1beta2.AnnotateTextResponse buildPartial() { com.google.cloud.language.v1beta2.AnnotateTextResponse result = new com.google.cloud.language.v1beta2.AnnotateTextResponse(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.language.v1beta2.AnnotateTextResponse .getDefaultInstance())) .setSchemaDescriptor( new LanguageServiceMethodDescriptorSupplier("AnnotateText"))
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; for (int i = 0; i < sentences_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, sentences_.get(i)); } for (int i = 0; i < tokens_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, tokens_.get(i)); } for (int i = 0; i < entities_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, entities_.get(i)); } if (documentSentiment_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getDocumentSentiment()); } if (!getLanguageBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, language_); } for (int i = 0; i < categories_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, categories_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@Test @SuppressWarnings("all") public void annotateTextTest() { String language = "language-1613589672"; AnnotateTextResponse expectedResponse = AnnotateTextResponse.newBuilder().setLanguage(language).build(); mockLanguageService.addResponse(expectedResponse); Document document = Document.newBuilder().build(); AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build(); EncodingType encodingType = EncodingType.NONE; AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests(); Assert.assertEquals(1, actualRequests.size()); AnnotateTextRequest actualRequest = (AnnotateTextRequest) actualRequests.get(0); Assert.assertEquals(document, actualRequest.getDocument()); Assert.assertEquals(features, actualRequest.getFeatures()); Assert.assertEquals(encodingType, actualRequest.getEncodingType()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }