congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Message$Builder.getRepeatedFieldBuilder
Code IndexAdd Tabnine to your IDE (free)

How to use
getRepeatedFieldBuilder
method
in
com.google.protobuf.Message$Builder

Best Java code snippets using com.google.protobuf.Message$Builder.getRepeatedFieldBuilder (Showing top 5 results out of 315)

origin: google/bundletool

 /** Recursively crawls the proto message while clearing each field of type {@link Source}. */
 @VisibleForTesting
 static void stripSourceReferences(Message.Builder msg) {
  for (FieldDescriptor fieldDesc : msg.getAllFields().keySet()) {
   if (!fieldDesc.getJavaType().equals(JavaType.MESSAGE)) {
    continue;
   }

   if (fieldDesc.getMessageType().getFullName().equals(Source.getDescriptor().getFullName())) {
    msg.clearField(fieldDesc);
   } else {
    if (fieldDesc.isRepeated()) {
     int repeatCount = msg.getRepeatedFieldCount(fieldDesc);
     for (int i = 0; i < repeatCount; i++) {
      stripSourceReferences(msg.getRepeatedFieldBuilder(fieldDesc, i));
     }
    } else {
     stripSourceReferences(msg.getFieldBuilder(fieldDesc));
    }
   }
  }
 }
}
origin: com.google.api/api-compiler

/**
 * Processes the deletion of children via a particular child field of the current node's
 * descriptor (e.g. fields within a message; nested message types within a message; etc).
 */
@Override public void processDeletedChildren(FieldDescriptor childFieldDesc) {
 Message.Builder parentBuilder = node();
 if (!toBeDeleted().isEmpty()) {
  if (getContainingFile() != null) {
   getContainingFile().processDeletedChildren(toBeDeleted());
  }
  List<Message.Builder> keepItems = new ArrayList<>();
  int fieldCount = parentBuilder.getRepeatedFieldCount(childFieldDesc);
  for (int i = 0; i < fieldCount; i++) {
   Message.Builder messageBuilder = parentBuilder.getRepeatedFieldBuilder(childFieldDesc, i);
   if (!toBeDeleted().contains(messageBuilder)) {
    keepItems.add(messageBuilder);
   }
  }
  toBeDeleted().clear();
  parentBuilder.clearField(childFieldDesc);
  for (Message.Builder newChild : keepItems) {
   parentBuilder.addRepeatedField(childFieldDesc, newChild.build());
  }
 }
}
origin: googleapis/api-compiler

/**
 * Processes the deletion of children via a particular child field of the current node's
 * descriptor (e.g. fields within a message; nested message types within a message; etc).
 */
@Override public void processDeletedChildren(FieldDescriptor childFieldDesc) {
 Message.Builder parentBuilder = node();
 if (!toBeDeleted().isEmpty()) {
  if (getContainingFile() != null) {
   getContainingFile().processDeletedChildren(toBeDeleted());
  }
  List<Message.Builder> keepItems = new ArrayList<>();
  int fieldCount = parentBuilder.getRepeatedFieldCount(childFieldDesc);
  for (int i = 0; i < fieldCount; i++) {
   Message.Builder messageBuilder = parentBuilder.getRepeatedFieldBuilder(childFieldDesc, i);
   if (!toBeDeleted().contains(messageBuilder)) {
    keepItems.add(messageBuilder);
   }
  }
  toBeDeleted().clear();
  parentBuilder.clearField(childFieldDesc);
  for (Message.Builder newChild : keepItems) {
   parentBuilder.addRepeatedField(childFieldDesc, newChild.build());
  }
 }
}
origin: com.google.api/api-compiler

protected void visitRepeated(int fieldNumber) {
 BuilderVisitorNodeInfo parentInfo = ancestors.peek();
 Message.Builder parentBuilder = (Message.Builder) parentInfo.node();
 FieldDescriptor fieldDesc = parentBuilder.getDescriptorForType().findFieldByNumber(fieldNumber);
 if (fieldDesc == null) {
  throw new RuntimeException(
    String.format(
      "BuilderVisitor internal error - bad field number %d for type %s",
      fieldNumber, parentBuilder.getDescriptorForType().getFullName()));
 }
 int fieldCount = parentBuilder.getRepeatedFieldCount(fieldDesc);
 for (int i = 0; i < fieldCount; i++) {
  Message.Builder element = parentBuilder.getRepeatedFieldBuilder(fieldDesc, i);
  // If we got in here via a FileDescriptor, let it know where we are in the traversal so it
  // can build up its path <-> proto element mappings.
  if (currentFile != null) {
   currentFile.pushChildPath(element, fieldNumber, i);
  }
  try {
   visit(element);
  } finally {
   if (currentFile != null) {
    currentFile.popChildPath();
   }
  }
 }
 parentInfo.processDeletedChildren(fieldDesc);
}
origin: googleapis/api-compiler

protected void visitRepeated(int fieldNumber) {
 BuilderVisitorNodeInfo parentInfo = ancestors.peek();
 Message.Builder parentBuilder = (Message.Builder) parentInfo.node();
 FieldDescriptor fieldDesc = parentBuilder.getDescriptorForType().findFieldByNumber(fieldNumber);
 if (fieldDesc == null) {
  throw new RuntimeException(
    String.format(
      "BuilderVisitor internal error - bad field number %d for type %s",
      fieldNumber, parentBuilder.getDescriptorForType().getFullName()));
 }
 int fieldCount = parentBuilder.getRepeatedFieldCount(fieldDesc);
 for (int i = 0; i < fieldCount; i++) {
  Message.Builder element = parentBuilder.getRepeatedFieldBuilder(fieldDesc, i);
  // If we got in here via a FileDescriptor, let it know where we are in the traversal so it
  // can build up its path <-> proto element mappings.
  if (currentFile != null) {
   currentFile.pushChildPath(element, fieldNumber, i);
  }
  try {
   visit(element);
  } finally {
   if (currentFile != null) {
    currentFile.popChildPath();
   }
  }
 }
 parentInfo.processDeletedChildren(fieldDesc);
}
com.google.protobufMessage$BuildergetRepeatedFieldBuilder

Javadoc

Get a nested builder instance for the given repeated field instance.

Normally, we hold a reference to the immutable message object for the message type field. Some implementations(the generated message builders), however, can also hold a reference to the builder object (a nested builder) for the field.

If the field is already backed up by a nested builder, the nested builder will be returned. Otherwise, a new field builder will be created and returned. The original message field (if exist) will be merged into the field builder, which will then be nested into its parent builder.

NOTE: implementations that do not support nested builders will throw UnsupportedOperationException.

Popular methods of Message$Builder

  • build
  • mergeFrom
  • setField
    Sets a field to the given value. The value must be of the correct type for this field, i.e. the same
  • getDescriptorForType
    Get the message's type's descriptor. See Message#getDescriptorForType().
  • newBuilderForField
    Create a Builder for messages of the appropriate type for the given field. Messages built with this
  • addRepeatedField
    Like setRepeatedField, but appends the value as a new element.
  • clearField
    Clears the field. This is exactly equivalent to calling the generated "clear" accessor method corres
  • getDefaultInstanceForType
  • buildPartial
  • getRepeatedFieldCount
  • hasField
  • setRepeatedField
    Sets an element of a repeated field to the given value. The value must be of the correct type for th
  • hasField,
  • setRepeatedField,
  • getField,
  • getOneofFieldDescriptor,
  • getFieldBuilder,
  • clearOneof,
  • getRepeatedField,
  • hasOneof,
  • mergeDelimitedFrom

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now