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

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

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

Any.getValue介绍

[英]```
Must be a valid serialized protocol buffer of the above specified type.

`optional bytes value = 2;`
[中]```
Must be a valid serialized protocol buffer of the above specified type.

optional bytes value = 2;

代码示例

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

@java.lang.Override
public boolean equals(final java.lang.Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof com.google.protobuf.Any)) {
  return super.equals(obj);
 }
 com.google.protobuf.Any other = (com.google.protobuf.Any) obj;
 boolean result = true;
 result = result && getTypeUrl()
   .equals(other.getTypeUrl());
 result = result && getValue()
   .equals(other.getValue());
 result = result && unknownFields.equals(other.unknownFields);
 return result;
}

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

@Override
  public void serialize(Any value, JsonGenerator jgen, SerializerProvider provider)
      throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    jgen.writeStringField(JSON_TYPE, value.getTypeUrl());
    jgen.writeBinaryField(JSON_VALUE, value.getValue().toByteArray());
    jgen.writeEndObject();
  }
}

代码示例来源: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();
 hash = (37 * hash) + TYPE_URL_FIELD_NUMBER;
 hash = (53 * hash) + getTypeUrl().hashCode();
 hash = (37 * hash) + VALUE_FIELD_NUMBER;
 hash = (53 * hash) + getValue().hashCode();
 hash = (29 * hash) + unknownFields.hashCode();
 memoizedHashCode = hash;
 return hash;
}

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

/**
 * <pre>
 * Must be a valid serialized protocol buffer of the above specified type.
 * </pre>
 *
 * <code>bytes value = 2;</code>
 */
public Builder clearValue() {
 
 value_ = getDefaultInstance().getValue();
 onChanged();
 return this;
}
@java.lang.Override

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

@java.lang.SuppressWarnings("unchecked")
public <T extends com.google.protobuf.Message> T unpack(
  java.lang.Class<T> clazz)
  throws com.google.protobuf.InvalidProtocolBufferException {
 if (!is(clazz)) {
  throw new com.google.protobuf.InvalidProtocolBufferException(
    "Type of the Any message does not match the given class.");
 }
 if (cachedUnpackValue != null) {
  return (T) cachedUnpackValue;
 }
 T defaultInstance =
   com.google.protobuf.Internal.getDefaultInstance(clazz);
 T result = (T) defaultInstance.getParserForType()
   .parseFrom(getValue());
 cachedUnpackValue = result;
 return result;
}
public static final int TYPE_URL_FIELD_NUMBER = 1;

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

public Builder mergeFrom(com.google.protobuf.Any other) {
 if (other == com.google.protobuf.Any.getDefaultInstance()) return this;
 if (!other.getTypeUrl().isEmpty()) {
  typeUrl_ = other.typeUrl_;
  onChanged();
 }
 if (other.getValue() != com.google.protobuf.ByteString.EMPTY) {
  setValue(other.getValue());
 }
 this.mergeUnknownFields(other.unknownFields);
 onChanged();
 return this;
}

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

/**
 * <pre>
 * Must be a valid serialized protocol buffer of the above specified type.
 * </pre>
 *
 * <code>optional bytes value = 2;</code>
 */
public com.google.protobuf.ByteString getValue() {
 return instance.getValue();
}
/**

代码示例来源:origin: com.google.api/api-compiler

private <T> T parseAny(Any value, Parser<T> parser) {
 try {
  return parser.parseFrom(value.getValue());
 } catch (InvalidProtocolBufferException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: googleapis/api-compiler

private <T> T parseAny(Any value, Parser<T> parser) {
 try {
  return parser.parseFrom(value.getValue());
 } catch (InvalidProtocolBufferException e) {
  throw new RuntimeException(e);
 }
}

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

/**
 * <pre>
 * Must be a valid serialized protocol buffer of the above specified type.
 * </pre>
 *
 * <code>optional bytes value = 2;</code>
 */
private void clearValue() {
 
 value_ = getDefaultInstance().getValue();
}

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

@Override
  public void serialize(Any value, JsonGenerator jgen, SerializerProvider provider)
      throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    jgen.writeStringField(JSON_TYPE, value.getTypeUrl());
    jgen.writeBinaryField(JSON_VALUE, value.getValue().toByteArray());
    jgen.writeEndObject();
  }
}

代码示例来源:origin: microbean/microbean-helm

for (final Any file : files) {
 if (file != null && "requirements.yaml".equals(file.getTypeUrl())) {
  final ByteString fileContents = file.getValue();
  if (fileContents != null) {
   final String yamlString = fileContents.toStringUtf8();

代码示例来源:origin: org.microbean/microbean-helm

for (final Any file : files) {
 if (file != null && "requirements.yaml".equals(file.getTypeUrl())) {
  final ByteString fileContents = file.getValue();
  if (fileContents != null) {
   final String yamlString = fileContents.toStringUtf8();

代码示例来源:origin: googleapis/api-compiler

/**
 * Attempt to unpack if its an any instance. Returns null if not unpacked.
 */
@Nullable private Message maybeUnpackAnyType(FieldDescriptor field, Object value) {
 if (field.getType() == FieldDescriptor.Type.MESSAGE
   && field.getMessageType().getFullName().equals(Any.getDescriptor().getFullName())) {
  Any any = (Any) value;
  Message defaultInstance = anyConverterRegistry.get(any.getTypeUrl());
  if (defaultInstance != null) {
   try {
    return defaultInstance.toBuilder().mergeFrom(any.getValue()).build();
   } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException(e);
   }
  }
 }
 return null;
}

相关文章