本文整理了Java中com.google.protobuf.Struct
类的一些代码示例,展示了Struct
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Struct
类的具体详情如下:
包路径:com.google.protobuf.Struct
类名称:Struct
[英]```Struct
represents a structured data value, consisting of fields
which map to dynamically typed values. In some languages, Struct
might be supported by a native representation. For example, in
scripting languages like JS a struct is represented as an
object. The details of that representation are described together
with the proto support for the language.
The JSON representation for Struct
is JSON object.
Protobuf type google.protobuf.Struct
[中]```
`Struct` represents a structured data value, consisting of fields
which map to dynamically typed values. In some languages, `Struct`
might be supported by a native representation. For example, in
scripting languages like JS a struct is represented as an
object. The details of that representation are described together
with the proto support for the language.
The JSON representation for `Struct` is JSON object.
Protobuf类型谷歌。protobuf。结构
代码示例来源:origin: com.google.protobuf/protobuf-java
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* <pre>
* Represents a structured value.
* </pre>
*
* <code>.google.protobuf.Struct struct_value = 5;</code>
*/
public com.google.protobuf.StructOrBuilder getStructValueOrBuilder() {
if ((kindCase_ == 5) && (structValueBuilder_ != null)) {
return structValueBuilder_.getMessageOrBuilder();
} else {
if (kindCase_ == 5) {
return (com.google.protobuf.Struct) kind_;
}
return com.google.protobuf.Struct.getDefaultInstance();
}
}
/**
代码示例来源:origin: com.google.protobuf/protobuf-java
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(com.google.protobuf.Struct prototype) {
代码示例来源:origin: com.google.protobuf/protobuf-java
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (!internalGetFields().getMap().isEmpty()) {
hash = (37 * hash) + FIELDS_FIELD_NUMBER;
hash = (53 * hash) + internalGetFields().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
代码示例来源: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>
* Output only. Data transfer specific parameters.
* </pre>
*
* <code>.google.protobuf.Struct params = 9;</code>
*/
public com.google.protobuf.Struct getParams() {
if (paramsBuilder_ == null) {
return params_ == null ? com.google.protobuf.Struct.getDefaultInstance() : params_;
} else {
return paramsBuilder_.getMessage();
}
}
/**
代码示例来源: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
subBuilder = payload_.toBuilder();
payload_ = input.readMessage(com.google.protobuf.Struct.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(payload_);
代码示例来源:origin: com.google.protobuf/protobuf-java
@java.lang.Override
public com.google.protobuf.Struct getDefaultInstanceForType() {
return com.google.protobuf.Struct.getDefaultInstance();
}
代码示例来源:origin: googleapis/google-cloud-java
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + SOURCE_FIELD_NUMBER;
hash = (53 * hash) + getSource().hashCode();
if (hasPayload()) {
hash = (37 * hash) + PAYLOAD_FIELD_NUMBER;
hash = (53 * hash) + getPayload().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
代码示例来源:origin: googleapis/google-cloud-java
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof com.google.cloud.dialogflow.v2.OriginalDetectIntentRequest)) {
return super.equals(obj);
}
com.google.cloud.dialogflow.v2.OriginalDetectIntentRequest other =
(com.google.cloud.dialogflow.v2.OriginalDetectIntentRequest) obj;
boolean result = true;
result = result && getSource().equals(other.getSource());
result = result && (hasPayload() == other.hasPayload());
if (hasPayload()) {
result = result && getPayload().equals(other.getPayload());
}
result = result && unknownFields.equals(other.unknownFields);
return result;
}
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* Use {@link #getFieldsMap()} instead.
*/
@java.lang.Deprecated
public java.util.Map<java.lang.String, com.google.protobuf.Value> getFields() {
return getFieldsMap();
}
/**
代码示例来源: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()
);
}
}
代码示例来源: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>
* Data transfer specific parameters.
* </pre>
*
* <code>.google.protobuf.Struct params = 9;</code>
*/
public com.google.protobuf.Struct getParams() {
if (paramsBuilder_ == null) {
return params_ == null ? com.google.protobuf.Struct.getDefaultInstance() : params_;
} else {
return paramsBuilder_.getMessage();
}
}
/**
代码示例来源:origin: googleapis/google-cloud-java
subBuilder = parameters_.toBuilder();
input.readMessage(com.google.protobuf.Struct.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(parameters_);
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* <pre>
* Represents a structured value.
* </pre>
*
* <code>.google.protobuf.Struct struct_value = 5;</code>
*/
public com.google.protobuf.StructOrBuilder getStructValueOrBuilder() {
if (kindCase_ == 5) {
return (com.google.protobuf.Struct) kind_;
}
return com.google.protobuf.Struct.getDefaultInstance();
}
代码示例来源:origin: googleapis/google-cloud-java
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
if (hasParameters()) {
hash = (37 * hash) + PARAMETERS_FIELD_NUMBER;
hash = (53 * hash) + getParameters().hashCode();
}
hash = (37 * hash) + LANGUAGE_CODE_FIELD_NUMBER;
hash = (53 * hash) + getLanguageCode().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
代码示例来源:origin: googleapis/google-cloud-java
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof com.google.cloud.dialogflow.v2beta1.OriginalDetectIntentRequest)) {
return super.equals(obj);
}
com.google.cloud.dialogflow.v2beta1.OriginalDetectIntentRequest other =
(com.google.cloud.dialogflow.v2beta1.OriginalDetectIntentRequest) obj;
boolean result = true;
result = result && getSource().equals(other.getSource());
result = result && getVersion().equals(other.getVersion());
result = result && (hasPayload() == other.hasPayload());
if (hasPayload()) {
result = result && getPayload().equals(other.getPayload());
}
result = result && unknownFields.equals(other.unknownFields);
return result;
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public int size() {
return struct.getFieldsMap().size();
}
}
内容来源于网络,如有侵权,请联系作者删除!