/** * * * <pre> * The enabled features. * </pre> * * <code>.google.cloud.language.v1beta2.AnnotateTextRequest.Features features = 2;</code> */ public Builder setFeatures( com.google.cloud.language.v1beta2.AnnotateTextRequest.Features.Builder builderForValue) { if (featuresBuilder_ == null) { features_ = builderForValue.build(); onChanged(); } else { featuresBuilder_.setMessage(builderForValue.build()); } return this; } /**
extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(features_); features_ = subBuilder.buildPartial();
/** * * * <pre> * The enabled features. * </pre> * * <code>.google.cloud.language.v1beta2.AnnotateTextRequest.Features features = 2;</code> */ public Builder mergeFeatures( com.google.cloud.language.v1beta2.AnnotateTextRequest.Features value) { if (featuresBuilder_ == null) { if (features_ != null) { features_ = com.google.cloud.language.v1beta2.AnnotateTextRequest.Features.newBuilder(features_) .mergeFrom(value) .buildPartial(); } else { features_ = value; } onChanged(); } else { featuresBuilder_.mergeFrom(value); } return this; } /**
public Builder mergeFrom( com.google.cloud.language.v1beta2.AnnotateTextRequest.Features other) { if (other == com.google.cloud.language.v1beta2.AnnotateTextRequest.Features.getDefaultInstance()) return this; if (other.getExtractSyntax() != false) { setExtractSyntax(other.getExtractSyntax()); } if (other.getExtractEntities() != false) { setExtractEntities(other.getExtractEntities()); } if (other.getExtractDocumentSentiment() != false) { setExtractDocumentSentiment(other.getExtractDocumentSentiment()); } if (other.getExtractEntitySentiment() != false) { setExtractEntitySentiment(other.getExtractEntitySentiment()); } if (other.getClassifyText() != false) { setClassifyText(other.getClassifyText()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.cloud.language.v1beta2.AnnotateTextRequest.Features parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.cloud.language.v1beta2.AnnotateTextRequest.Features) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
@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())); }
/** * * * <pre> * Extract entities and their associated sentiment. * </pre> * * <code>bool extract_entity_sentiment = 4;</code> */ public Builder setExtractEntitySentiment(boolean value) { extractEntitySentiment_ = value; onChanged(); return this; } /**
@Test @SuppressWarnings("all") public void annotateTextExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockLanguageService.addException(exception); try { Document document = Document.newBuilder().build(); AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build(); EncodingType encodingType = EncodingType.NONE; client.annotateText(document, features, encodingType); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } } }
/** * * * <pre> * Extract syntax information. * </pre> * * <code>bool extract_syntax = 1;</code> */ public Builder setExtractSyntax(boolean value) { extractSyntax_ = value; onChanged(); return this; } /**
/** * * * <pre> * Extract document-level sentiment. * </pre> * * <code>bool extract_document_sentiment = 3;</code> */ public Builder setExtractDocumentSentiment(boolean value) { extractDocumentSentiment_ = value; onChanged(); return this; } /**
/** * * * <pre> * Extract entities and their associated sentiment. * </pre> * * <code>bool extract_entity_sentiment = 4;</code> */ public Builder clearExtractEntitySentiment() { extractEntitySentiment_ = false; onChanged(); return this; }
/** * * * <pre> * Classify the full document into categories. * </pre> * * <code>bool classify_text = 6;</code> */ public Builder setClassifyText(boolean value) { classifyText_ = value; onChanged(); return this; } /**
/** * * * <pre> * Extract entities. * </pre> * * <code>bool extract_entities = 2;</code> */ public Builder setExtractEntities(boolean value) { extractEntities_ = value; onChanged(); return this; } /**
/** * * * <pre> * Extract entities. * </pre> * * <code>bool extract_entities = 2;</code> */ public Builder clearExtractEntities() { extractEntities_ = false; onChanged(); return this; }
private Builder() { maybeForceBuilderInitialization(); }
/** * * * <pre> * Classify the full document into categories. * </pre> * * <code>bool classify_text = 6;</code> */ public Builder clearClassifyText() { classifyText_ = false; onChanged(); return this; }
/** * * * <pre> * Extract document-level sentiment. * </pre> * * <code>bool extract_document_sentiment = 3;</code> */ public Builder clearExtractDocumentSentiment() { extractDocumentSentiment_ = false; onChanged(); return this; }
/** * * * <pre> * Extract syntax information. * </pre> * * <code>bool extract_syntax = 1;</code> */ public Builder clearExtractSyntax() { extractSyntax_ = false; onChanged(); return this; }
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); }