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

x33g5p2x  于2022-01-30 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(552)

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

Struct.newBuilder介绍

暂无

代码示例

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

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

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

/**
 * Creates a new {@link Struct} object given the content of the provided {@code map} parameter.
 *
 * <p>Notice that all numbers (int, long, float and double) are serialized as double values. Enums
 * are serialized as strings.
 */
static Struct newStruct(Map<String, ?> map) {
 Map<String, Value> valueMap = Maps.transformValues(checkNotNull(map), OBJECT_TO_VALUE);
 return Struct.newBuilder().putAllFields(valueMap).build();
}

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

/**
 *
 *
 * <pre>
 * Output only. Data transfer specific parameters.
 * </pre>
 *
 * <code>.google.protobuf.Struct params = 9;</code>
 */
public Builder mergeParams(com.google.protobuf.Struct value) {
 if (paramsBuilder_ == null) {
  if (params_ != null) {
   params_ = com.google.protobuf.Struct.newBuilder(params_).mergeFrom(value).buildPartial();
  } else {
   params_ = value;
  }
  onChanged();
 } else {
  paramsBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Data transfer specific parameters.
 * </pre>
 *
 * <code>.google.protobuf.Struct params = 9;</code>
 */
public Builder mergeParams(com.google.protobuf.Struct value) {
 if (paramsBuilder_ == null) {
  if (params_ != null) {
   params_ = com.google.protobuf.Struct.newBuilder(params_).mergeFrom(value).buildPartial();
  } else {
   params_ = value;
  }
  onChanged();
 } else {
  paramsBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * The collection of extracted parameters.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 4;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * The collection of extracted parameters.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 4;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. The collection of parameters associated with the event.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 2;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. The collection of parameters associated with the event.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 2;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * The content of the resource, in which some sensitive fields are scrubbed
 * away and may not be present.
 * </pre>
 *
 * <code>.google.protobuf.Struct data = 6;</code>
 */
public Builder mergeData(com.google.protobuf.Struct value) {
 if (dataBuilder_ == null) {
  if (data_ != null) {
   data_ = com.google.protobuf.Struct.newBuilder(data_).mergeFrom(value).buildPartial();
  } else {
   data_ = value;
  }
  onChanged();
 } else {
  dataBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. This field is set to the value of `QueryParameters.payload` field
 * passed in the request.
 * </pre>
 *
 * <code>.google.protobuf.Struct payload = 3;</code>
 */
public Builder mergePayload(com.google.protobuf.Struct value) {
 if (payloadBuilder_ == null) {
  if (payload_ != null) {
   payload_ =
     com.google.protobuf.Struct.newBuilder(payload_).mergeFrom(value).buildPartial();
  } else {
   payload_ = value;
  }
  onChanged();
 } else {
  payloadBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. This field can be used to pass custom data into the webhook
 * associated with the agent. Arbitrary JSON objects are supported.
 * </pre>
 *
 * <code>.google.protobuf.Struct payload = 6;</code>
 */
public Builder mergePayload(com.google.protobuf.Struct value) {
 if (payloadBuilder_ == null) {
  if (payload_ != null) {
   payload_ =
     com.google.protobuf.Struct.newBuilder(payload_).mergeFrom(value).buildPartial();
  } else {
   payload_ = value;
  }
  onChanged();
 } else {
  payloadBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. This field can be used to pass custom data into the webhook
 * associated with the agent. Arbitrary JSON objects are supported.
 * </pre>
 *
 * <code>.google.protobuf.Struct payload = 6;</code>
 */
public Builder mergePayload(com.google.protobuf.Struct value) {
 if (payloadBuilder_ == null) {
  if (payload_ != null) {
   payload_ =
     com.google.protobuf.Struct.newBuilder(payload_).mergeFrom(value).buildPartial();
  } else {
   payload_ = value;
  }
  onChanged();
 } else {
  payloadBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. The collection of parameters associated with this context.
 * Refer to [this doc](https://dialogflow.com/docs/actions-and-parameters) for
 * syntax.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 3;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * If the query was fulfilled by a webhook call, this field is set to the
 * value of the `payload` field returned in the webhook response.
 * </pre>
 *
 * <code>.google.protobuf.Struct webhook_payload = 9;</code>
 */
public Builder mergeWebhookPayload(com.google.protobuf.Struct value) {
 if (webhookPayloadBuilder_ == null) {
  if (webhookPayload_ != null) {
   webhookPayload_ =
     com.google.protobuf.Struct.newBuilder(webhookPayload_)
       .mergeFrom(value)
       .buildPartial();
  } else {
   webhookPayload_ = value;
  }
  onChanged();
 } else {
  webhookPayloadBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * The free-form diagnostic info. For example, this field
 * could contain webhook call latency.
 * </pre>
 *
 * <code>.google.protobuf.Struct diagnostic_info = 14;</code>
 */
public Builder mergeDiagnosticInfo(com.google.protobuf.Struct value) {
 if (diagnosticInfoBuilder_ == null) {
  if (diagnosticInfo_ != null) {
   diagnosticInfo_ =
     com.google.protobuf.Struct.newBuilder(diagnosticInfo_)
       .mergeFrom(value)
       .buildPartial();
  } else {
   diagnosticInfo_ = value;
  }
  onChanged();
 } else {
  diagnosticInfoBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * If the query was fulfilled by a webhook call, this field is set to the
 * value of the `payload` field returned in the webhook response.
 * </pre>
 *
 * <code>.google.protobuf.Struct webhook_payload = 9;</code>
 */
public Builder mergeWebhookPayload(com.google.protobuf.Struct value) {
 if (webhookPayloadBuilder_ == null) {
  if (webhookPayload_ != null) {
   webhookPayload_ =
     com.google.protobuf.Struct.newBuilder(webhookPayload_)
       .mergeFrom(value)
       .buildPartial();
  } else {
   webhookPayload_ = value;
  }
  onChanged();
 } else {
  webhookPayloadBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * The free-form diagnostic info. For example, this field
 * could contain webhook call latency.
 * </pre>
 *
 * <code>.google.protobuf.Struct diagnostic_info = 14;</code>
 */
public Builder mergeDiagnosticInfo(com.google.protobuf.Struct value) {
 if (diagnosticInfoBuilder_ == null) {
  if (diagnosticInfo_ != null) {
   diagnosticInfo_ =
     com.google.protobuf.Struct.newBuilder(diagnosticInfo_)
       .mergeFrom(value)
       .buildPartial();
  } else {
   diagnosticInfo_ = value;
  }
  onChanged();
 } else {
  diagnosticInfoBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

/**
 * <pre>
 * Represents a structured value.
 * </pre>
 *
 * <code>.google.protobuf.Struct struct_value = 5;</code>
 */
public Builder mergeStructValue(com.google.protobuf.Struct value) {
 if (structValueBuilder_ == null) {
  if (kindCase_ == 5 &&
    kind_ != com.google.protobuf.Struct.getDefaultInstance()) {
   kind_ = com.google.protobuf.Struct.newBuilder((com.google.protobuf.Struct) kind_)
     .mergeFrom(value).buildPartial();
  } else {
   kind_ = value;
  }
  onChanged();
 } else {
  if (kindCase_ == 5) {
   structValueBuilder_.mergeFrom(value);
  }
  structValueBuilder_.setMessage(value);
 }
 kindCase_ = 5;
 return this;
}
/**

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

/**
 *
 *
 * <pre>
 * Optional. The collection of parameters associated with this context.
 * Refer to [this doc](https://dialogflow.com/docs/actions-and-parameters) for
 * syntax.
 * </pre>
 *
 * <code>.google.protobuf.Struct parameters = 3;</code>
 */
public Builder mergeParameters(com.google.protobuf.Struct value) {
 if (parametersBuilder_ == null) {
  if (parameters_ != null) {
   parameters_ =
     com.google.protobuf.Struct.newBuilder(parameters_).mergeFrom(value).buildPartial();
  } else {
   parameters_ = value;
  }
  onChanged();
 } else {
  parametersBuilder_.mergeFrom(value);
 }
 return this;
}
/**

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

@Test
  public void testSimpleMapping() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper m = new JsonMapperProvider().get();
    assertTrue(m.canSerialize(Any.class));

    Struct struct1 = Struct.newBuilder().putFields(
        "some-key", Value.newBuilder().setStringValue("some-value").build()
    ).build();

    Any source = Any.pack(struct1);

    StringWriter buf = new StringWriter();
    m.writer().writeValue(buf, source);

    Any dest = m.reader().forType(Any.class).readValue(buf.toString());
    assertEquals(source.getTypeUrl(), dest.getTypeUrl());

    Struct struct2 = dest.unpack(Struct.class);
    assertTrue(struct2.containsFields("some-key"));
    assertEquals(
        struct1.getFieldsOrThrow("some-key").getStringValue(),
        struct2.getFieldsOrThrow("some-key").getStringValue()
    );
  }
}

相关文章