com.google.protobuf.Any.newBuilder()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(442)

本文整理了Java中com.google.protobuf.Any.newBuilder()方法的一些代码示例,展示了Any.newBuilder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Any.newBuilder()方法的具体详情如下:
包路径:com.google.protobuf.Any
类名称:Any
方法名:newBuilder

Any.newBuilder介绍

暂无

代码示例

代码示例来源:origin: com.google.protobuf/protobuf-java

@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {

代码示例来源:origin: Netflix/conductor

@Override
  public Any deserialize(JsonParser p, DeserializationContext ctxt)
      throws IOException, JsonProcessingException {
    JsonNode root = p.getCodec().readTree(p);
    JsonNode type = root.get(JSON_TYPE);
    JsonNode value = root.get(JSON_VALUE);
    if (type == null || !type.isTextual()) {
      throw ctxt.reportMappingException("invalid '@type' field when deserializing ProtoBuf Any object");
    }
    if (value == null || !value.isTextual()) {
      throw ctxt.reportMappingException("invalid '@value' field when deserializing ProtoBuf Any object");
    }
    return Any.newBuilder()
        .setTypeUrl(type.textValue())
        .setValue(ByteString.copyFrom(value.binaryValue()))
        .build();
  }
}

代码示例来源:origin: com.google.protobuf/protobuf-java

/**
 * <pre>
 * The option's value packed in an Any message. If the value is a primitive,
 * the corresponding wrapper type defined in google/protobuf/wrappers.proto
 * should be used. If the value is an enum, it should be stored as an int32
 * value using the google.protobuf.Int32Value type.
 * </pre>
 *
 * <code>.google.protobuf.Any value = 2;</code>
 */
public Builder mergeValue(com.google.protobuf.Any value) {
 if (valueBuilder_ == null) {
  if (value_ != null) {
   value_ =
    com.google.protobuf.Any.newBuilder(value_).mergeFrom(value).buildPartial();
  } else {
   value_ = value;
  }
  onChanged();
 } else {
  valueBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: googleapis/google-cloud-java

if (payloadCase_ == 2 && payload_ != com.google.protobuf.Any.getDefaultInstance()) {
 payload_ =
   com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) payload_)
     .mergeFrom(value)
     .buildPartial();

代码示例来源:origin: com.google.protobuf/protobuf-java

public static <T extends com.google.protobuf.Message> Any pack(
  T message) {
 return Any.newBuilder()
   .setTypeUrl(getTypeUrl("type.googleapis.com",
               message.getDescriptorForType()))
   .setValue(message.toByteString())
   .build();
}

代码示例来源:origin: com.google.protobuf/protobuf-java

/**
 * Packs a message using the given type URL prefix. The type URL will
 * be constructed by concatenating the message type's full name to the
 * prefix with an optional "/" separator if the prefix doesn't end
 * with "/" already.
 */
public static <T extends com.google.protobuf.Message> Any pack(
  T message, java.lang.String typeUrlPrefix) {
 return Any.newBuilder()
   .setTypeUrl(getTypeUrl(typeUrlPrefix,
               message.getDescriptorForType()))
   .setValue(message.toByteString())
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

static Any toAny(Message message) {
 return Any.newBuilder()
   .setTypeUrl("type.googleapis.com/" + message.getDescriptorForType().getFullName())
   .setValue(message.toByteString())
   .build();
}

代码示例来源:origin: com.netflix.conductor/conductor-common

@Override
  public Any deserialize(JsonParser p, DeserializationContext ctxt)
      throws IOException, JsonProcessingException {
    JsonNode root = p.getCodec().readTree(p);
    JsonNode type = root.get(JSON_TYPE);
    JsonNode value = root.get(JSON_VALUE);
    if (type == null || !type.isTextual()) {
      throw ctxt.reportMappingException("invalid '@type' field when deserializing ProtoBuf Any object");
    }
    if (value == null || !value.isTextual()) {
      throw ctxt.reportMappingException("invalid '@value' field when deserializing ProtoBuf Any object");
    }
    return Any.newBuilder()
        .setTypeUrl(type.textValue())
        .setValue(ByteString.copyFrom(value.binaryValue()))
        .build();
  }
}

代码示例来源:origin: ks-no/eventstore2

/**
 * <code>optional .google.protobuf.Any event = 8;</code>
 */
public Builder mergeEvent(com.google.protobuf.Any value) {
 if (eventBuilder_ == null) {
  if (event_ != null) {
   event_ =
    com.google.protobuf.Any.newBuilder(event_).mergeFrom(value).buildPartial();
  } else {
   event_ = value;
  }
  onChanged();
 } else {
  eventBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: org.tensorflow/proto

/**
 * <pre>
 * A serialized protobuf. Can be the time this meta graph is created, or
 * modified, or name of the model.
 * </pre>
 *
 * <code>.google.protobuf.Any any_info = 3;</code>
 */
public Builder mergeAnyInfo(com.google.protobuf.Any value) {
 if (anyInfoBuilder_ == null) {
  if (anyInfo_ != null) {
   anyInfo_ =
    com.google.protobuf.Any.newBuilder(anyInfo_).mergeFrom(value).buildPartial();
  } else {
   anyInfo_ = value;
  }
  onChanged();
 } else {
  anyInfoBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: chenjunwen/SpringBootFrame

/**
 * <pre>
 *返回数据体
 * </pre>
 *
 * <code>.google.protobuf.Any body = 5;</code>
 */
public Builder mergeBody(com.google.protobuf.Any value) {
 if (bodyBuilder_ == null) {
  if (body_ != null) {
   body_ =
    com.google.protobuf.Any.newBuilder(body_).mergeFrom(value).buildPartial();
  } else {
   body_ = value;
  }
  onChanged();
 } else {
  bodyBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: envoyproxy/java-control-plane

/**
 * <pre>
 * The resource being tracked.
 * </pre>
 *
 * <code>.google.protobuf.Any resource = 2;</code>
 */
public Builder mergeResource(com.google.protobuf.Any value) {
 if (resourceBuilder_ == null) {
  if (resource_ != null) {
   resource_ =
    com.google.protobuf.Any.newBuilder(resource_).mergeFrom(value).buildPartial();
  } else {
   resource_ = value;
  }
  onChanged();
 } else {
  resourceBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: com.google.api.grpc/grpc-google-genomics-v1

/**
 * <pre>
 * Runtime metadata on this Operation.
 * </pre>
 *
 * <code>optional .google.protobuf.Any runtime_metadata = 8;</code>
 */
public Builder mergeRuntimeMetadata(com.google.protobuf.Any value) {
 if (runtimeMetadataBuilder_ == null) {
  if (runtimeMetadata_ != null) {
   runtimeMetadata_ =
    com.google.protobuf.Any.newBuilder(runtimeMetadata_).mergeFrom(value).buildPartial();
  } else {
   runtimeMetadata_ = value;
  }
  onChanged();
 } else {
  runtimeMetadataBuilder_.mergeFrom(value);
 }
 return this;
}
/**

代码示例来源:origin: com.athaydes.protobuf/protobuf-tcp-rpc

/**
 * <code>optional .google.protobuf.Any successResult = 1;</code>
 */
public Builder mergeSuccessResult(com.google.protobuf.Any value) {
 if (successResultBuilder_ == null) {
  if (resultCase_ == 1 &&
    result_ != com.google.protobuf.Any.getDefaultInstance()) {
   result_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) result_)
     .mergeFrom(value).buildPartial();
  } else {
   result_ = value;
  }
  onChanged();
 } else {
  if (resultCase_ == 1) {
   successResultBuilder_.mergeFrom(value);
  }
  successResultBuilder_.setMessage(value);
 }
 resultCase_ = 1;
 return this;
}
/**

代码示例来源:origin: envoyproxy/java-control-plane

/**
 * <code>.google.protobuf.Any typed_config = 3;</code>
 */
public Builder mergeTypedConfig(com.google.protobuf.Any value) {
 if (typedConfigBuilder_ == null) {
  if (configTypeCase_ == 3 &&
    configType_ != com.google.protobuf.Any.getDefaultInstance()) {
   configType_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) configType_)
     .mergeFrom(value).buildPartial();
  } else {
   configType_ = value;
  }
  onChanged();
 } else {
  if (configTypeCase_ == 3) {
   typedConfigBuilder_.mergeFrom(value);
  }
  typedConfigBuilder_.setMessage(value);
 }
 configTypeCase_ = 3;
 return this;
}
/**

代码示例来源:origin: envoyproxy/java-control-plane

/**
 * <code>.google.protobuf.Any typed_config = 3;</code>
 */
public Builder mergeTypedConfig(com.google.protobuf.Any value) {
 if (typedConfigBuilder_ == null) {
  if (configTypeCase_ == 3 &&
    configType_ != com.google.protobuf.Any.getDefaultInstance()) {
   configType_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) configType_)
     .mergeFrom(value).buildPartial();
  } else {
   configType_ = value;
  }
  onChanged();
 } else {
  if (configTypeCase_ == 3) {
   typedConfigBuilder_.mergeFrom(value);
  }
  typedConfigBuilder_.setMessage(value);
 }
 configTypeCase_ = 3;
 return this;
}
/**

代码示例来源:origin: envoyproxy/java-control-plane

/**
 * <code>.google.protobuf.Any typed_config = 3;</code>
 */
public Builder mergeTypedConfig(com.google.protobuf.Any value) {
 if (typedConfigBuilder_ == null) {
  if (configTypeCase_ == 3 &&
    configType_ != com.google.protobuf.Any.getDefaultInstance()) {
   configType_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) configType_)
     .mergeFrom(value).buildPartial();
  } else {
   configType_ = value;
  }
  onChanged();
 } else {
  if (configTypeCase_ == 3) {
   typedConfigBuilder_.mergeFrom(value);
  }
  typedConfigBuilder_.setMessage(value);
 }
 configTypeCase_ = 3;
 return this;
}
/**

代码示例来源:origin: envoyproxy/java-control-plane

/**
 * <code>.google.protobuf.Any typed_config = 3;</code>
 */
public Builder mergeTypedConfig(com.google.protobuf.Any value) {
 if (typedConfigBuilder_ == null) {
  if (configTypeCase_ == 3 &&
    configType_ != com.google.protobuf.Any.getDefaultInstance()) {
   configType_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) configType_)
     .mergeFrom(value).buildPartial();
  } else {
   configType_ = value;
  }
  onChanged();
 } else {
  if (configTypeCase_ == 3) {
   typedConfigBuilder_.mergeFrom(value);
  }
  typedConfigBuilder_.setMessage(value);
 }
 configTypeCase_ = 3;
 return this;
}
/**

代码示例来源:origin: yeriomin/play-store-api

/**
 * <pre>
 * The option's value. For example, `"com.google.protobuf"`.
 * </pre>
 *
 * <code>optional .google.protobuf.Any value = 2;</code>
 */
private void mergeValue(com.google.protobuf.Any value) {
 if (value_ != null &&
   value_ != com.google.protobuf.Any.getDefaultInstance()) {
  value_ =
   com.google.protobuf.Any.newBuilder(value_).mergeFrom(value).buildPartial();
 } else {
  value_ = value;
 }
 
}
/**

代码示例来源:origin: com.hubspot.jackson/jackson-datatype-protobuf

/**
 * <code>.google.protobuf.Any any = 1;</code>
 */
public Builder mergeAny(com.google.protobuf.Any value) {
 if (anyBuilder_ == null) {
  if (any_ != null) {
   any_ =
    com.google.protobuf.Any.newBuilder(any_).mergeFrom(value).buildPartial();
  } else {
   any_ = value;
  }
  onChanged();
 } else {
  anyBuilder_.mergeFrom(value);
 }
 return this;
}
/**

相关文章