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

x33g5p2x  于2022-01-24 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(251)

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

Message.getDefaultInstanceForType介绍

暂无

代码示例

代码示例来源:origin: google/truth

  1. private static Message orDefaultForType(
  2. @NullableDecl Message input, @NullableDecl Message other) {
  3. return (input != null) ? input : other.getDefaultInstanceForType();
  4. }

代码示例来源:origin: org.apache.hadoop/hadoop-common

  1. private Message getReturnMessage(final Method method,
  2. final RpcWritable.Buffer buf) throws ServiceException {
  3. Message prototype = null;
  4. try {
  5. prototype = getReturnProtoType(method);
  6. } catch (Exception e) {
  7. throw new ServiceException(e);
  8. }
  9. Message returnMessage;
  10. try {
  11. returnMessage = buf.getValue(prototype.getDefaultInstanceForType());
  12. if (LOG.isTraceEnabled()) {
  13. LOG.trace(Thread.currentThread().getId() + ": Response <- " +
  14. remoteId + ": " + method.getName() +
  15. " {" + TextFormat.shortDebugString(returnMessage) + "}");
  16. }
  17. } catch (Throwable e) {
  18. throw new ServiceException(e);
  19. }
  20. return returnMessage;
  21. }

代码示例来源:origin: apache/hbase

  1. public static Message getResponse(
  2. org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse
  3. result,
  4. com.google.protobuf.Message responsePrototype)
  5. throws IOException {
  6. Message response;
  7. if (result.getValue().hasValue()) {
  8. Message.Builder builder = responsePrototype.newBuilderForType();
  9. builder.mergeFrom(result.getValue().getValue().newInput());
  10. response = builder.build();
  11. } else {
  12. response = responsePrototype.getDefaultInstanceForType();
  13. }
  14. if (LOG.isTraceEnabled()) {
  15. LOG.trace("Master Result is value=" + response);
  16. }
  17. return response;
  18. }

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

  1. if (existingValue == existingValue.getDefaultInstanceForType()) {
  2. setField(field, entry.getValue());
  3. } else {

代码示例来源:origin: line/armeria

  1. private Message deserializeProto(ByteBuf buf, Message prototype) throws IOException {
  2. if (GrpcSerializationFormats.isProto(serializationFormat)) {
  3. if (!buf.isReadable()) {
  4. return prototype.getDefaultInstanceForType();

代码示例来源:origin: osmandapp/Osmand

  1. if (existingValue == existingValue.getDefaultInstanceForType()) {
  2. setField(field, entry.getValue());
  3. } else {

代码示例来源:origin: google/truth

  1. actualFields.get(fieldDescriptor),
  2. expectedFields.get(fieldDescriptor),
  3. actual.getDefaultInstanceForType().getField(fieldDescriptor),
  4. shouldCompare == FieldScopeResult.EXCLUDED_NONRECURSIVELY,
  5. fieldDescriptor,

代码示例来源:origin: google/bundletool

  1. private boolean isDefaultTargeting(T splittingDimensionTargeting) {
  2. return splittingDimensionTargeting.equals(
  3. splittingDimensionTargeting.getDefaultInstanceForType());
  4. }

代码示例来源:origin: org.apache.hbase/hbase-client

  1. public static Message getResponse(
  2. org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse
  3. result,
  4. com.google.protobuf.Message responsePrototype)
  5. throws IOException {
  6. Message response;
  7. if (result.getValue().hasValue()) {
  8. Message.Builder builder = responsePrototype.newBuilderForType();
  9. builder.mergeFrom(result.getValue().getValue().newInput());
  10. response = builder.build();
  11. } else {
  12. response = responsePrototype.getDefaultInstanceForType();
  13. }
  14. if (LOG.isTraceEnabled()) {
  15. LOG.trace("Master Result is value=" + response);
  16. }
  17. return response;
  18. }

代码示例来源:origin: com.google.truth.extensions/truth-proto-extension

  1. private static Message orDefaultForType(
  2. @NullableDecl Message input, @NullableDecl Message other) {
  3. return (input != null) ? input : other.getDefaultInstanceForType();
  4. }

代码示例来源:origin: io.hops/hadoop-common

  1. private Message getReturnMessage(final Method method,
  2. final RpcWritable.Buffer buf) throws ServiceException {
  3. Message prototype = null;
  4. try {
  5. prototype = getReturnProtoType(method);
  6. } catch (Exception e) {
  7. throw new ServiceException(e);
  8. }
  9. Message returnMessage;
  10. try {
  11. returnMessage = buf.getValue(prototype.getDefaultInstanceForType());
  12. if (LOG.isTraceEnabled()) {
  13. LOG.trace(Thread.currentThread().getId() + ": Response <- " +
  14. remoteId + ": " + method.getName() +
  15. " {" + TextFormat.shortDebugString(returnMessage) + "}");
  16. }
  17. } catch (Throwable e) {
  18. throw new ServiceException(e);
  19. }
  20. return returnMessage;
  21. }

代码示例来源:origin: com.github.protobufel/protobufel

  1. /**
  2. * Merges the field from another field.
  3. *
  4. * @param value the value to merge from
  5. * @return the builder
  6. */
  7. public SingleFieldBuilder<MType, BType, IType> mergeFrom(final MType value) {
  8. if (builder == null && message == message.getDefaultInstanceForType()) {
  9. message = value;
  10. } else {
  11. getBuilder().mergeFrom(value);
  12. }
  13. onChanged();
  14. return this;
  15. }

代码示例来源:origin: com.google.openrtb/openrtb-core

  1. } else {
  2. @SuppressWarnings("unchecked")
  3. M ret = (M) msg.getDefaultInstanceForType();
  4. return ret;

代码示例来源:origin: com.github.protobufel/protobufel

  1. /**
  2. * Clears the value of the field.
  3. *
  4. * @return the builder
  5. */
  6. @Override
  7. @SuppressWarnings("unchecked")
  8. public void clear() {
  9. message =
  10. (MType) (message != null ? message.getDefaultInstanceForType() : builder
  11. .getDefaultInstanceForType());
  12. if (builder != null) {
  13. dispose(builder);
  14. builder = null;
  15. }
  16. onChanged();
  17. }

代码示例来源:origin: com.aliyun.hbase/alihbase-client

  1. public static Message getResponse(
  2. org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse
  3. result,
  4. com.google.protobuf.Message responsePrototype)
  5. throws IOException {
  6. Message response;
  7. if (result.getValue().hasValue()) {
  8. Message.Builder builder = responsePrototype.newBuilderForType();
  9. builder.mergeFrom(result.getValue().getValue().newInput());
  10. response = builder.build();
  11. } else {
  12. response = responsePrototype.getDefaultInstanceForType();
  13. }
  14. if (LOG.isTraceEnabled()) {
  15. LOG.trace("Master Result is value=" + response);
  16. }
  17. return response;
  18. }

代码示例来源:origin: WeAreFairphone/FP2-Launcher

  1. if (existingValue == existingValue.getDefaultInstanceForType()) {
  2. setField(field, entry.getValue());
  3. } else {

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

  1. if (existingValue == existingValue.getDefaultInstanceForType()) {
  2. setField(field, entry.getValue());
  3. } else {

代码示例来源:origin: com.linecorp.armeria/armeria-grpc

  1. private Message deserializeProto(ByteBuf buf, Message prototype) throws IOException {
  2. if (GrpcSerializationFormats.isProto(serializationFormat)) {
  3. if (!buf.isReadable()) {
  4. return prototype.getDefaultInstanceForType();

代码示例来源:origin: blueapron/kafka-connect-protobuf-converter

  1. if (message == message.getDefaultInstanceForType()) {
  2. return null;

代码示例来源:origin: com.google.truth.extensions/truth-proto-extension

  1. actualFields.get(fieldDescriptor),
  2. expectedFields.get(fieldDescriptor),
  3. actual.getDefaultInstanceForType().getField(fieldDescriptor),
  4. shouldIgnore.shouldIgnoreNonRecursive(),
  5. fieldDescriptor,

相关文章