1 /* 2 * Copyright 2020 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 // Generated by the protocol buffer compiler. DO NOT EDIT! 17 // source: google/cloud/vision/v1p1beta1/image_annotator.proto 18 19 package com.google.cloud.vision.v1p1beta1; 20 21 /** 22 * 23 * 24 * <pre> 25 * Users describe the type of Google Cloud Vision API tasks to perform over 26 * images by using *Feature*s. Each Feature indicates a type of image 27 * detection task to perform. Features encode the Cloud Vision API 28 * vertical to operate on and the number of top-scoring results to return. 29 * </pre> 30 * 31 * Protobuf type {@code google.cloud.vision.v1p1beta1.Feature} 32 */ 33 public final class Feature extends com.google.protobuf.GeneratedMessageV3 34 implements 35 // @@protoc_insertion_point(message_implements:google.cloud.vision.v1p1beta1.Feature) 36 FeatureOrBuilder { 37 private static final long serialVersionUID = 0L; 38 // Use Feature.newBuilder() to construct. Feature(com.google.protobuf.GeneratedMessageV3.Builder<?> builder)39 private Feature(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { 40 super(builder); 41 } 42 Feature()43 private Feature() { 44 type_ = 0; 45 model_ = ""; 46 } 47 48 @java.lang.Override 49 @SuppressWarnings({"unused"}) newInstance(UnusedPrivateParameter unused)50 protected java.lang.Object newInstance(UnusedPrivateParameter unused) { 51 return new Feature(); 52 } 53 54 @java.lang.Override getUnknownFields()55 public final com.google.protobuf.UnknownFieldSet getUnknownFields() { 56 return this.unknownFields; 57 } 58 getDescriptor()59 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 60 return com.google.cloud.vision.v1p1beta1.ImageAnnotatorProto 61 .internal_static_google_cloud_vision_v1p1beta1_Feature_descriptor; 62 } 63 64 @java.lang.Override 65 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()66 internalGetFieldAccessorTable() { 67 return com.google.cloud.vision.v1p1beta1.ImageAnnotatorProto 68 .internal_static_google_cloud_vision_v1p1beta1_Feature_fieldAccessorTable 69 .ensureFieldAccessorsInitialized( 70 com.google.cloud.vision.v1p1beta1.Feature.class, 71 com.google.cloud.vision.v1p1beta1.Feature.Builder.class); 72 } 73 74 /** 75 * 76 * 77 * <pre> 78 * Type of image feature. 79 * </pre> 80 * 81 * Protobuf enum {@code google.cloud.vision.v1p1beta1.Feature.Type} 82 */ 83 public enum Type implements com.google.protobuf.ProtocolMessageEnum { 84 /** 85 * 86 * 87 * <pre> 88 * Unspecified feature type. 89 * </pre> 90 * 91 * <code>TYPE_UNSPECIFIED = 0;</code> 92 */ 93 TYPE_UNSPECIFIED(0), 94 /** 95 * 96 * 97 * <pre> 98 * Run face detection. 99 * </pre> 100 * 101 * <code>FACE_DETECTION = 1;</code> 102 */ 103 FACE_DETECTION(1), 104 /** 105 * 106 * 107 * <pre> 108 * Run landmark detection. 109 * </pre> 110 * 111 * <code>LANDMARK_DETECTION = 2;</code> 112 */ 113 LANDMARK_DETECTION(2), 114 /** 115 * 116 * 117 * <pre> 118 * Run logo detection. 119 * </pre> 120 * 121 * <code>LOGO_DETECTION = 3;</code> 122 */ 123 LOGO_DETECTION(3), 124 /** 125 * 126 * 127 * <pre> 128 * Run label detection. 129 * </pre> 130 * 131 * <code>LABEL_DETECTION = 4;</code> 132 */ 133 LABEL_DETECTION(4), 134 /** 135 * 136 * 137 * <pre> 138 * Run OCR. 139 * </pre> 140 * 141 * <code>TEXT_DETECTION = 5;</code> 142 */ 143 TEXT_DETECTION(5), 144 /** 145 * 146 * 147 * <pre> 148 * Run dense text document OCR. Takes precedence when both 149 * DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. 150 * </pre> 151 * 152 * <code>DOCUMENT_TEXT_DETECTION = 11;</code> 153 */ 154 DOCUMENT_TEXT_DETECTION(11), 155 /** 156 * 157 * 158 * <pre> 159 * Run computer vision models to compute image safe-search properties. 160 * </pre> 161 * 162 * <code>SAFE_SEARCH_DETECTION = 6;</code> 163 */ 164 SAFE_SEARCH_DETECTION(6), 165 /** 166 * 167 * 168 * <pre> 169 * Compute a set of image properties, such as the image's dominant colors. 170 * </pre> 171 * 172 * <code>IMAGE_PROPERTIES = 7;</code> 173 */ 174 IMAGE_PROPERTIES(7), 175 /** 176 * 177 * 178 * <pre> 179 * Run crop hints. 180 * </pre> 181 * 182 * <code>CROP_HINTS = 9;</code> 183 */ 184 CROP_HINTS(9), 185 /** 186 * 187 * 188 * <pre> 189 * Run web detection. 190 * </pre> 191 * 192 * <code>WEB_DETECTION = 10;</code> 193 */ 194 WEB_DETECTION(10), 195 UNRECOGNIZED(-1), 196 ; 197 198 /** 199 * 200 * 201 * <pre> 202 * Unspecified feature type. 203 * </pre> 204 * 205 * <code>TYPE_UNSPECIFIED = 0;</code> 206 */ 207 public static final int TYPE_UNSPECIFIED_VALUE = 0; 208 /** 209 * 210 * 211 * <pre> 212 * Run face detection. 213 * </pre> 214 * 215 * <code>FACE_DETECTION = 1;</code> 216 */ 217 public static final int FACE_DETECTION_VALUE = 1; 218 /** 219 * 220 * 221 * <pre> 222 * Run landmark detection. 223 * </pre> 224 * 225 * <code>LANDMARK_DETECTION = 2;</code> 226 */ 227 public static final int LANDMARK_DETECTION_VALUE = 2; 228 /** 229 * 230 * 231 * <pre> 232 * Run logo detection. 233 * </pre> 234 * 235 * <code>LOGO_DETECTION = 3;</code> 236 */ 237 public static final int LOGO_DETECTION_VALUE = 3; 238 /** 239 * 240 * 241 * <pre> 242 * Run label detection. 243 * </pre> 244 * 245 * <code>LABEL_DETECTION = 4;</code> 246 */ 247 public static final int LABEL_DETECTION_VALUE = 4; 248 /** 249 * 250 * 251 * <pre> 252 * Run OCR. 253 * </pre> 254 * 255 * <code>TEXT_DETECTION = 5;</code> 256 */ 257 public static final int TEXT_DETECTION_VALUE = 5; 258 /** 259 * 260 * 261 * <pre> 262 * Run dense text document OCR. Takes precedence when both 263 * DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. 264 * </pre> 265 * 266 * <code>DOCUMENT_TEXT_DETECTION = 11;</code> 267 */ 268 public static final int DOCUMENT_TEXT_DETECTION_VALUE = 11; 269 /** 270 * 271 * 272 * <pre> 273 * Run computer vision models to compute image safe-search properties. 274 * </pre> 275 * 276 * <code>SAFE_SEARCH_DETECTION = 6;</code> 277 */ 278 public static final int SAFE_SEARCH_DETECTION_VALUE = 6; 279 /** 280 * 281 * 282 * <pre> 283 * Compute a set of image properties, such as the image's dominant colors. 284 * </pre> 285 * 286 * <code>IMAGE_PROPERTIES = 7;</code> 287 */ 288 public static final int IMAGE_PROPERTIES_VALUE = 7; 289 /** 290 * 291 * 292 * <pre> 293 * Run crop hints. 294 * </pre> 295 * 296 * <code>CROP_HINTS = 9;</code> 297 */ 298 public static final int CROP_HINTS_VALUE = 9; 299 /** 300 * 301 * 302 * <pre> 303 * Run web detection. 304 * </pre> 305 * 306 * <code>WEB_DETECTION = 10;</code> 307 */ 308 public static final int WEB_DETECTION_VALUE = 10; 309 getNumber()310 public final int getNumber() { 311 if (this == UNRECOGNIZED) { 312 throw new java.lang.IllegalArgumentException( 313 "Can't get the number of an unknown enum value."); 314 } 315 return value; 316 } 317 318 /** 319 * @param value The numeric wire value of the corresponding enum entry. 320 * @return The enum associated with the given numeric wire value. 321 * @deprecated Use {@link #forNumber(int)} instead. 322 */ 323 @java.lang.Deprecated valueOf(int value)324 public static Type valueOf(int value) { 325 return forNumber(value); 326 } 327 328 /** 329 * @param value The numeric wire value of the corresponding enum entry. 330 * @return The enum associated with the given numeric wire value. 331 */ forNumber(int value)332 public static Type forNumber(int value) { 333 switch (value) { 334 case 0: 335 return TYPE_UNSPECIFIED; 336 case 1: 337 return FACE_DETECTION; 338 case 2: 339 return LANDMARK_DETECTION; 340 case 3: 341 return LOGO_DETECTION; 342 case 4: 343 return LABEL_DETECTION; 344 case 5: 345 return TEXT_DETECTION; 346 case 11: 347 return DOCUMENT_TEXT_DETECTION; 348 case 6: 349 return SAFE_SEARCH_DETECTION; 350 case 7: 351 return IMAGE_PROPERTIES; 352 case 9: 353 return CROP_HINTS; 354 case 10: 355 return WEB_DETECTION; 356 default: 357 return null; 358 } 359 } 360 internalGetValueMap()361 public static com.google.protobuf.Internal.EnumLiteMap<Type> internalGetValueMap() { 362 return internalValueMap; 363 } 364 365 private static final com.google.protobuf.Internal.EnumLiteMap<Type> internalValueMap = 366 new com.google.protobuf.Internal.EnumLiteMap<Type>() { 367 public Type findValueByNumber(int number) { 368 return Type.forNumber(number); 369 } 370 }; 371 getValueDescriptor()372 public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { 373 if (this == UNRECOGNIZED) { 374 throw new java.lang.IllegalStateException( 375 "Can't get the descriptor of an unrecognized enum value."); 376 } 377 return getDescriptor().getValues().get(ordinal()); 378 } 379 getDescriptorForType()380 public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { 381 return getDescriptor(); 382 } 383 getDescriptor()384 public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { 385 return com.google.cloud.vision.v1p1beta1.Feature.getDescriptor().getEnumTypes().get(0); 386 } 387 388 private static final Type[] VALUES = values(); 389 valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc)390 public static Type valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { 391 if (desc.getType() != getDescriptor()) { 392 throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); 393 } 394 if (desc.getIndex() == -1) { 395 return UNRECOGNIZED; 396 } 397 return VALUES[desc.getIndex()]; 398 } 399 400 private final int value; 401 Type(int value)402 private Type(int value) { 403 this.value = value; 404 } 405 406 // @@protoc_insertion_point(enum_scope:google.cloud.vision.v1p1beta1.Feature.Type) 407 } 408 409 public static final int TYPE_FIELD_NUMBER = 1; 410 private int type_ = 0; 411 /** 412 * 413 * 414 * <pre> 415 * The feature type. 416 * </pre> 417 * 418 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 419 * 420 * @return The enum numeric value on the wire for type. 421 */ 422 @java.lang.Override getTypeValue()423 public int getTypeValue() { 424 return type_; 425 } 426 /** 427 * 428 * 429 * <pre> 430 * The feature type. 431 * </pre> 432 * 433 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 434 * 435 * @return The type. 436 */ 437 @java.lang.Override getType()438 public com.google.cloud.vision.v1p1beta1.Feature.Type getType() { 439 com.google.cloud.vision.v1p1beta1.Feature.Type result = 440 com.google.cloud.vision.v1p1beta1.Feature.Type.forNumber(type_); 441 return result == null ? com.google.cloud.vision.v1p1beta1.Feature.Type.UNRECOGNIZED : result; 442 } 443 444 public static final int MAX_RESULTS_FIELD_NUMBER = 2; 445 private int maxResults_ = 0; 446 /** 447 * 448 * 449 * <pre> 450 * Maximum number of results of this type. 451 * </pre> 452 * 453 * <code>int32 max_results = 2;</code> 454 * 455 * @return The maxResults. 456 */ 457 @java.lang.Override getMaxResults()458 public int getMaxResults() { 459 return maxResults_; 460 } 461 462 public static final int MODEL_FIELD_NUMBER = 3; 463 464 @SuppressWarnings("serial") 465 private volatile java.lang.Object model_ = ""; 466 /** 467 * 468 * 469 * <pre> 470 * Model to use for the feature. 471 * Supported values: "builtin/stable" (the default if unset) and 472 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 473 * support "builtin/weekly" for the bleeding edge release updated weekly. 474 * </pre> 475 * 476 * <code>string model = 3;</code> 477 * 478 * @return The model. 479 */ 480 @java.lang.Override getModel()481 public java.lang.String getModel() { 482 java.lang.Object ref = model_; 483 if (ref instanceof java.lang.String) { 484 return (java.lang.String) ref; 485 } else { 486 com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; 487 java.lang.String s = bs.toStringUtf8(); 488 model_ = s; 489 return s; 490 } 491 } 492 /** 493 * 494 * 495 * <pre> 496 * Model to use for the feature. 497 * Supported values: "builtin/stable" (the default if unset) and 498 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 499 * support "builtin/weekly" for the bleeding edge release updated weekly. 500 * </pre> 501 * 502 * <code>string model = 3;</code> 503 * 504 * @return The bytes for model. 505 */ 506 @java.lang.Override getModelBytes()507 public com.google.protobuf.ByteString getModelBytes() { 508 java.lang.Object ref = model_; 509 if (ref instanceof java.lang.String) { 510 com.google.protobuf.ByteString b = 511 com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); 512 model_ = b; 513 return b; 514 } else { 515 return (com.google.protobuf.ByteString) ref; 516 } 517 } 518 519 private byte memoizedIsInitialized = -1; 520 521 @java.lang.Override isInitialized()522 public final boolean isInitialized() { 523 byte isInitialized = memoizedIsInitialized; 524 if (isInitialized == 1) return true; 525 if (isInitialized == 0) return false; 526 527 memoizedIsInitialized = 1; 528 return true; 529 } 530 531 @java.lang.Override writeTo(com.google.protobuf.CodedOutputStream output)532 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { 533 if (type_ != com.google.cloud.vision.v1p1beta1.Feature.Type.TYPE_UNSPECIFIED.getNumber()) { 534 output.writeEnum(1, type_); 535 } 536 if (maxResults_ != 0) { 537 output.writeInt32(2, maxResults_); 538 } 539 if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(model_)) { 540 com.google.protobuf.GeneratedMessageV3.writeString(output, 3, model_); 541 } 542 getUnknownFields().writeTo(output); 543 } 544 545 @java.lang.Override getSerializedSize()546 public int getSerializedSize() { 547 int size = memoizedSize; 548 if (size != -1) return size; 549 550 size = 0; 551 if (type_ != com.google.cloud.vision.v1p1beta1.Feature.Type.TYPE_UNSPECIFIED.getNumber()) { 552 size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, type_); 553 } 554 if (maxResults_ != 0) { 555 size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, maxResults_); 556 } 557 if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(model_)) { 558 size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, model_); 559 } 560 size += getUnknownFields().getSerializedSize(); 561 memoizedSize = size; 562 return size; 563 } 564 565 @java.lang.Override equals(final java.lang.Object obj)566 public boolean equals(final java.lang.Object obj) { 567 if (obj == this) { 568 return true; 569 } 570 if (!(obj instanceof com.google.cloud.vision.v1p1beta1.Feature)) { 571 return super.equals(obj); 572 } 573 com.google.cloud.vision.v1p1beta1.Feature other = 574 (com.google.cloud.vision.v1p1beta1.Feature) obj; 575 576 if (type_ != other.type_) return false; 577 if (getMaxResults() != other.getMaxResults()) return false; 578 if (!getModel().equals(other.getModel())) return false; 579 if (!getUnknownFields().equals(other.getUnknownFields())) return false; 580 return true; 581 } 582 583 @java.lang.Override hashCode()584 public int hashCode() { 585 if (memoizedHashCode != 0) { 586 return memoizedHashCode; 587 } 588 int hash = 41; 589 hash = (19 * hash) + getDescriptor().hashCode(); 590 hash = (37 * hash) + TYPE_FIELD_NUMBER; 591 hash = (53 * hash) + type_; 592 hash = (37 * hash) + MAX_RESULTS_FIELD_NUMBER; 593 hash = (53 * hash) + getMaxResults(); 594 hash = (37 * hash) + MODEL_FIELD_NUMBER; 595 hash = (53 * hash) + getModel().hashCode(); 596 hash = (29 * hash) + getUnknownFields().hashCode(); 597 memoizedHashCode = hash; 598 return hash; 599 } 600 parseFrom(java.nio.ByteBuffer data)601 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom(java.nio.ByteBuffer data) 602 throws com.google.protobuf.InvalidProtocolBufferException { 603 return PARSER.parseFrom(data); 604 } 605 parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)606 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 607 java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 608 throws com.google.protobuf.InvalidProtocolBufferException { 609 return PARSER.parseFrom(data, extensionRegistry); 610 } 611 parseFrom( com.google.protobuf.ByteString data)612 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 613 com.google.protobuf.ByteString data) 614 throws com.google.protobuf.InvalidProtocolBufferException { 615 return PARSER.parseFrom(data); 616 } 617 parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)618 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 619 com.google.protobuf.ByteString data, 620 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 621 throws com.google.protobuf.InvalidProtocolBufferException { 622 return PARSER.parseFrom(data, extensionRegistry); 623 } 624 parseFrom(byte[] data)625 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom(byte[] data) 626 throws com.google.protobuf.InvalidProtocolBufferException { 627 return PARSER.parseFrom(data); 628 } 629 parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)630 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 631 byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 632 throws com.google.protobuf.InvalidProtocolBufferException { 633 return PARSER.parseFrom(data, extensionRegistry); 634 } 635 parseFrom(java.io.InputStream input)636 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom(java.io.InputStream input) 637 throws java.io.IOException { 638 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 639 } 640 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)641 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 642 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 643 throws java.io.IOException { 644 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 645 PARSER, input, extensionRegistry); 646 } 647 parseDelimitedFrom( java.io.InputStream input)648 public static com.google.cloud.vision.v1p1beta1.Feature parseDelimitedFrom( 649 java.io.InputStream input) throws java.io.IOException { 650 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); 651 } 652 parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)653 public static com.google.cloud.vision.v1p1beta1.Feature parseDelimitedFrom( 654 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 655 throws java.io.IOException { 656 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( 657 PARSER, input, extensionRegistry); 658 } 659 parseFrom( com.google.protobuf.CodedInputStream input)660 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 661 com.google.protobuf.CodedInputStream input) throws java.io.IOException { 662 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 663 } 664 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)665 public static com.google.cloud.vision.v1p1beta1.Feature parseFrom( 666 com.google.protobuf.CodedInputStream input, 667 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 668 throws java.io.IOException { 669 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 670 PARSER, input, extensionRegistry); 671 } 672 673 @java.lang.Override newBuilderForType()674 public Builder newBuilderForType() { 675 return newBuilder(); 676 } 677 newBuilder()678 public static Builder newBuilder() { 679 return DEFAULT_INSTANCE.toBuilder(); 680 } 681 newBuilder(com.google.cloud.vision.v1p1beta1.Feature prototype)682 public static Builder newBuilder(com.google.cloud.vision.v1p1beta1.Feature prototype) { 683 return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 684 } 685 686 @java.lang.Override toBuilder()687 public Builder toBuilder() { 688 return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); 689 } 690 691 @java.lang.Override newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)692 protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 693 Builder builder = new Builder(parent); 694 return builder; 695 } 696 /** 697 * 698 * 699 * <pre> 700 * Users describe the type of Google Cloud Vision API tasks to perform over 701 * images by using *Feature*s. Each Feature indicates a type of image 702 * detection task to perform. Features encode the Cloud Vision API 703 * vertical to operate on and the number of top-scoring results to return. 704 * </pre> 705 * 706 * Protobuf type {@code google.cloud.vision.v1p1beta1.Feature} 707 */ 708 public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> 709 implements 710 // @@protoc_insertion_point(builder_implements:google.cloud.vision.v1p1beta1.Feature) 711 com.google.cloud.vision.v1p1beta1.FeatureOrBuilder { getDescriptor()712 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 713 return com.google.cloud.vision.v1p1beta1.ImageAnnotatorProto 714 .internal_static_google_cloud_vision_v1p1beta1_Feature_descriptor; 715 } 716 717 @java.lang.Override 718 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()719 internalGetFieldAccessorTable() { 720 return com.google.cloud.vision.v1p1beta1.ImageAnnotatorProto 721 .internal_static_google_cloud_vision_v1p1beta1_Feature_fieldAccessorTable 722 .ensureFieldAccessorsInitialized( 723 com.google.cloud.vision.v1p1beta1.Feature.class, 724 com.google.cloud.vision.v1p1beta1.Feature.Builder.class); 725 } 726 727 // Construct using com.google.cloud.vision.v1p1beta1.Feature.newBuilder() Builder()728 private Builder() {} 729 Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)730 private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 731 super(parent); 732 } 733 734 @java.lang.Override clear()735 public Builder clear() { 736 super.clear(); 737 bitField0_ = 0; 738 type_ = 0; 739 maxResults_ = 0; 740 model_ = ""; 741 return this; 742 } 743 744 @java.lang.Override getDescriptorForType()745 public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { 746 return com.google.cloud.vision.v1p1beta1.ImageAnnotatorProto 747 .internal_static_google_cloud_vision_v1p1beta1_Feature_descriptor; 748 } 749 750 @java.lang.Override getDefaultInstanceForType()751 public com.google.cloud.vision.v1p1beta1.Feature getDefaultInstanceForType() { 752 return com.google.cloud.vision.v1p1beta1.Feature.getDefaultInstance(); 753 } 754 755 @java.lang.Override build()756 public com.google.cloud.vision.v1p1beta1.Feature build() { 757 com.google.cloud.vision.v1p1beta1.Feature result = buildPartial(); 758 if (!result.isInitialized()) { 759 throw newUninitializedMessageException(result); 760 } 761 return result; 762 } 763 764 @java.lang.Override buildPartial()765 public com.google.cloud.vision.v1p1beta1.Feature buildPartial() { 766 com.google.cloud.vision.v1p1beta1.Feature result = 767 new com.google.cloud.vision.v1p1beta1.Feature(this); 768 if (bitField0_ != 0) { 769 buildPartial0(result); 770 } 771 onBuilt(); 772 return result; 773 } 774 buildPartial0(com.google.cloud.vision.v1p1beta1.Feature result)775 private void buildPartial0(com.google.cloud.vision.v1p1beta1.Feature result) { 776 int from_bitField0_ = bitField0_; 777 if (((from_bitField0_ & 0x00000001) != 0)) { 778 result.type_ = type_; 779 } 780 if (((from_bitField0_ & 0x00000002) != 0)) { 781 result.maxResults_ = maxResults_; 782 } 783 if (((from_bitField0_ & 0x00000004) != 0)) { 784 result.model_ = model_; 785 } 786 } 787 788 @java.lang.Override clone()789 public Builder clone() { 790 return super.clone(); 791 } 792 793 @java.lang.Override setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)794 public Builder setField( 795 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 796 return super.setField(field, value); 797 } 798 799 @java.lang.Override clearField(com.google.protobuf.Descriptors.FieldDescriptor field)800 public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { 801 return super.clearField(field); 802 } 803 804 @java.lang.Override clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)805 public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { 806 return super.clearOneof(oneof); 807 } 808 809 @java.lang.Override setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value)810 public Builder setRepeatedField( 811 com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { 812 return super.setRepeatedField(field, index, value); 813 } 814 815 @java.lang.Override addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)816 public Builder addRepeatedField( 817 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 818 return super.addRepeatedField(field, value); 819 } 820 821 @java.lang.Override mergeFrom(com.google.protobuf.Message other)822 public Builder mergeFrom(com.google.protobuf.Message other) { 823 if (other instanceof com.google.cloud.vision.v1p1beta1.Feature) { 824 return mergeFrom((com.google.cloud.vision.v1p1beta1.Feature) other); 825 } else { 826 super.mergeFrom(other); 827 return this; 828 } 829 } 830 mergeFrom(com.google.cloud.vision.v1p1beta1.Feature other)831 public Builder mergeFrom(com.google.cloud.vision.v1p1beta1.Feature other) { 832 if (other == com.google.cloud.vision.v1p1beta1.Feature.getDefaultInstance()) return this; 833 if (other.type_ != 0) { 834 setTypeValue(other.getTypeValue()); 835 } 836 if (other.getMaxResults() != 0) { 837 setMaxResults(other.getMaxResults()); 838 } 839 if (!other.getModel().isEmpty()) { 840 model_ = other.model_; 841 bitField0_ |= 0x00000004; 842 onChanged(); 843 } 844 this.mergeUnknownFields(other.getUnknownFields()); 845 onChanged(); 846 return this; 847 } 848 849 @java.lang.Override isInitialized()850 public final boolean isInitialized() { 851 return true; 852 } 853 854 @java.lang.Override mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)855 public Builder mergeFrom( 856 com.google.protobuf.CodedInputStream input, 857 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 858 throws java.io.IOException { 859 if (extensionRegistry == null) { 860 throw new java.lang.NullPointerException(); 861 } 862 try { 863 boolean done = false; 864 while (!done) { 865 int tag = input.readTag(); 866 switch (tag) { 867 case 0: 868 done = true; 869 break; 870 case 8: 871 { 872 type_ = input.readEnum(); 873 bitField0_ |= 0x00000001; 874 break; 875 } // case 8 876 case 16: 877 { 878 maxResults_ = input.readInt32(); 879 bitField0_ |= 0x00000002; 880 break; 881 } // case 16 882 case 26: 883 { 884 model_ = input.readStringRequireUtf8(); 885 bitField0_ |= 0x00000004; 886 break; 887 } // case 26 888 default: 889 { 890 if (!super.parseUnknownField(input, extensionRegistry, tag)) { 891 done = true; // was an endgroup tag 892 } 893 break; 894 } // default: 895 } // switch (tag) 896 } // while (!done) 897 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 898 throw e.unwrapIOException(); 899 } finally { 900 onChanged(); 901 } // finally 902 return this; 903 } 904 905 private int bitField0_; 906 907 private int type_ = 0; 908 /** 909 * 910 * 911 * <pre> 912 * The feature type. 913 * </pre> 914 * 915 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 916 * 917 * @return The enum numeric value on the wire for type. 918 */ 919 @java.lang.Override getTypeValue()920 public int getTypeValue() { 921 return type_; 922 } 923 /** 924 * 925 * 926 * <pre> 927 * The feature type. 928 * </pre> 929 * 930 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 931 * 932 * @param value The enum numeric value on the wire for type to set. 933 * @return This builder for chaining. 934 */ setTypeValue(int value)935 public Builder setTypeValue(int value) { 936 type_ = value; 937 bitField0_ |= 0x00000001; 938 onChanged(); 939 return this; 940 } 941 /** 942 * 943 * 944 * <pre> 945 * The feature type. 946 * </pre> 947 * 948 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 949 * 950 * @return The type. 951 */ 952 @java.lang.Override getType()953 public com.google.cloud.vision.v1p1beta1.Feature.Type getType() { 954 com.google.cloud.vision.v1p1beta1.Feature.Type result = 955 com.google.cloud.vision.v1p1beta1.Feature.Type.forNumber(type_); 956 return result == null ? com.google.cloud.vision.v1p1beta1.Feature.Type.UNRECOGNIZED : result; 957 } 958 /** 959 * 960 * 961 * <pre> 962 * The feature type. 963 * </pre> 964 * 965 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 966 * 967 * @param value The type to set. 968 * @return This builder for chaining. 969 */ setType(com.google.cloud.vision.v1p1beta1.Feature.Type value)970 public Builder setType(com.google.cloud.vision.v1p1beta1.Feature.Type value) { 971 if (value == null) { 972 throw new NullPointerException(); 973 } 974 bitField0_ |= 0x00000001; 975 type_ = value.getNumber(); 976 onChanged(); 977 return this; 978 } 979 /** 980 * 981 * 982 * <pre> 983 * The feature type. 984 * </pre> 985 * 986 * <code>.google.cloud.vision.v1p1beta1.Feature.Type type = 1;</code> 987 * 988 * @return This builder for chaining. 989 */ clearType()990 public Builder clearType() { 991 bitField0_ = (bitField0_ & ~0x00000001); 992 type_ = 0; 993 onChanged(); 994 return this; 995 } 996 997 private int maxResults_; 998 /** 999 * 1000 * 1001 * <pre> 1002 * Maximum number of results of this type. 1003 * </pre> 1004 * 1005 * <code>int32 max_results = 2;</code> 1006 * 1007 * @return The maxResults. 1008 */ 1009 @java.lang.Override getMaxResults()1010 public int getMaxResults() { 1011 return maxResults_; 1012 } 1013 /** 1014 * 1015 * 1016 * <pre> 1017 * Maximum number of results of this type. 1018 * </pre> 1019 * 1020 * <code>int32 max_results = 2;</code> 1021 * 1022 * @param value The maxResults to set. 1023 * @return This builder for chaining. 1024 */ setMaxResults(int value)1025 public Builder setMaxResults(int value) { 1026 1027 maxResults_ = value; 1028 bitField0_ |= 0x00000002; 1029 onChanged(); 1030 return this; 1031 } 1032 /** 1033 * 1034 * 1035 * <pre> 1036 * Maximum number of results of this type. 1037 * </pre> 1038 * 1039 * <code>int32 max_results = 2;</code> 1040 * 1041 * @return This builder for chaining. 1042 */ clearMaxResults()1043 public Builder clearMaxResults() { 1044 bitField0_ = (bitField0_ & ~0x00000002); 1045 maxResults_ = 0; 1046 onChanged(); 1047 return this; 1048 } 1049 1050 private java.lang.Object model_ = ""; 1051 /** 1052 * 1053 * 1054 * <pre> 1055 * Model to use for the feature. 1056 * Supported values: "builtin/stable" (the default if unset) and 1057 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 1058 * support "builtin/weekly" for the bleeding edge release updated weekly. 1059 * </pre> 1060 * 1061 * <code>string model = 3;</code> 1062 * 1063 * @return The model. 1064 */ getModel()1065 public java.lang.String getModel() { 1066 java.lang.Object ref = model_; 1067 if (!(ref instanceof java.lang.String)) { 1068 com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; 1069 java.lang.String s = bs.toStringUtf8(); 1070 model_ = s; 1071 return s; 1072 } else { 1073 return (java.lang.String) ref; 1074 } 1075 } 1076 /** 1077 * 1078 * 1079 * <pre> 1080 * Model to use for the feature. 1081 * Supported values: "builtin/stable" (the default if unset) and 1082 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 1083 * support "builtin/weekly" for the bleeding edge release updated weekly. 1084 * </pre> 1085 * 1086 * <code>string model = 3;</code> 1087 * 1088 * @return The bytes for model. 1089 */ getModelBytes()1090 public com.google.protobuf.ByteString getModelBytes() { 1091 java.lang.Object ref = model_; 1092 if (ref instanceof String) { 1093 com.google.protobuf.ByteString b = 1094 com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); 1095 model_ = b; 1096 return b; 1097 } else { 1098 return (com.google.protobuf.ByteString) ref; 1099 } 1100 } 1101 /** 1102 * 1103 * 1104 * <pre> 1105 * Model to use for the feature. 1106 * Supported values: "builtin/stable" (the default if unset) and 1107 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 1108 * support "builtin/weekly" for the bleeding edge release updated weekly. 1109 * </pre> 1110 * 1111 * <code>string model = 3;</code> 1112 * 1113 * @param value The model to set. 1114 * @return This builder for chaining. 1115 */ setModel(java.lang.String value)1116 public Builder setModel(java.lang.String value) { 1117 if (value == null) { 1118 throw new NullPointerException(); 1119 } 1120 model_ = value; 1121 bitField0_ |= 0x00000004; 1122 onChanged(); 1123 return this; 1124 } 1125 /** 1126 * 1127 * 1128 * <pre> 1129 * Model to use for the feature. 1130 * Supported values: "builtin/stable" (the default if unset) and 1131 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 1132 * support "builtin/weekly" for the bleeding edge release updated weekly. 1133 * </pre> 1134 * 1135 * <code>string model = 3;</code> 1136 * 1137 * @return This builder for chaining. 1138 */ clearModel()1139 public Builder clearModel() { 1140 model_ = getDefaultInstance().getModel(); 1141 bitField0_ = (bitField0_ & ~0x00000004); 1142 onChanged(); 1143 return this; 1144 } 1145 /** 1146 * 1147 * 1148 * <pre> 1149 * Model to use for the feature. 1150 * Supported values: "builtin/stable" (the default if unset) and 1151 * "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also 1152 * support "builtin/weekly" for the bleeding edge release updated weekly. 1153 * </pre> 1154 * 1155 * <code>string model = 3;</code> 1156 * 1157 * @param value The bytes for model to set. 1158 * @return This builder for chaining. 1159 */ setModelBytes(com.google.protobuf.ByteString value)1160 public Builder setModelBytes(com.google.protobuf.ByteString value) { 1161 if (value == null) { 1162 throw new NullPointerException(); 1163 } 1164 checkByteStringIsUtf8(value); 1165 model_ = value; 1166 bitField0_ |= 0x00000004; 1167 onChanged(); 1168 return this; 1169 } 1170 1171 @java.lang.Override setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields)1172 public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { 1173 return super.setUnknownFields(unknownFields); 1174 } 1175 1176 @java.lang.Override mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields)1177 public final Builder mergeUnknownFields( 1178 final com.google.protobuf.UnknownFieldSet unknownFields) { 1179 return super.mergeUnknownFields(unknownFields); 1180 } 1181 1182 // @@protoc_insertion_point(builder_scope:google.cloud.vision.v1p1beta1.Feature) 1183 } 1184 1185 // @@protoc_insertion_point(class_scope:google.cloud.vision.v1p1beta1.Feature) 1186 private static final com.google.cloud.vision.v1p1beta1.Feature DEFAULT_INSTANCE; 1187 1188 static { 1189 DEFAULT_INSTANCE = new com.google.cloud.vision.v1p1beta1.Feature(); 1190 } 1191 getDefaultInstance()1192 public static com.google.cloud.vision.v1p1beta1.Feature getDefaultInstance() { 1193 return DEFAULT_INSTANCE; 1194 } 1195 1196 private static final com.google.protobuf.Parser<Feature> PARSER = 1197 new com.google.protobuf.AbstractParser<Feature>() { 1198 @java.lang.Override 1199 public Feature parsePartialFrom( 1200 com.google.protobuf.CodedInputStream input, 1201 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1202 throws com.google.protobuf.InvalidProtocolBufferException { 1203 Builder builder = newBuilder(); 1204 try { 1205 builder.mergeFrom(input, extensionRegistry); 1206 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1207 throw e.setUnfinishedMessage(builder.buildPartial()); 1208 } catch (com.google.protobuf.UninitializedMessageException e) { 1209 throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); 1210 } catch (java.io.IOException e) { 1211 throw new com.google.protobuf.InvalidProtocolBufferException(e) 1212 .setUnfinishedMessage(builder.buildPartial()); 1213 } 1214 return builder.buildPartial(); 1215 } 1216 }; 1217 parser()1218 public static com.google.protobuf.Parser<Feature> parser() { 1219 return PARSER; 1220 } 1221 1222 @java.lang.Override getParserForType()1223 public com.google.protobuf.Parser<Feature> getParserForType() { 1224 return PARSER; 1225 } 1226 1227 @java.lang.Override getDefaultInstanceForType()1228 public com.google.cloud.vision.v1p1beta1.Feature getDefaultInstanceForType() { 1229 return DEFAULT_INSTANCE; 1230 } 1231 } 1232