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

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

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

Message.equals介绍

[英]Compares the specified object with this message for equality. Returns true if the given object is a message of the same type (as defined by getDescriptorForType()) and has identical values for all of its fields. Subclasses must implement this; inheriting Object.equals() is incorrect.
[中]将指定的对象与此消息进行比较,以确定是否相等。如果给定对象是相同类型的消息(由getDescriptorForType()定义),并且其所有字段的值都相同,则返回true。子类必须实现这一点;继承对象。equals()不正确。

代码示例

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

@Override
public boolean matches(Object item) {
 if (item == null || !(expected.getClass().isAssignableFrom(item.getClass()))) {
  return false;
 }
 @SuppressWarnings("unchecked") // Type checked above.
 T actual = (T) item;
 return expected.equals(actual);
}

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

private boolean isDefaultTargeting(T splittingDimensionTargeting) {
 return splittingDimensionTargeting.equals(
   splittingDimensionTargeting.getDefaultInstanceForType());
}

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

@Override
public boolean equals(Object object) {
 if (object instanceof ProtobufDatum) {
  ProtobufDatum another = (ProtobufDatum) object;
  return value.equals(another.value);
 } else {
  return false;
 }
}

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

@Override
public boolean equals(Object object) {
 if (object instanceof ProtobufDatum) {
  ProtobufDatum another = (ProtobufDatum) object;
  return value.equals(another.value);
 } else {
  return false;
 }
}

代码示例来源:origin: xyz.codemeans.protobuf4j/protobuf4j-core

@Override
public boolean isEmpty(T msg) {
 return msg == null || defaultValue().equals(msg);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-common

@Override
public boolean equals(Object other) {
 if (other == null)
  return false;
 if (other.getClass().isAssignableFrom(this.getClass())) {
  return this.getProto().equals(this.getClass().cast(other).getProto());
 }
 return false;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

@Override
public boolean equals(Object other) {
 if (other == null)
  return false;
 if (other.getClass().isAssignableFrom(this.getClass())) {
  return this.getProto().equals(this.getClass().cast(other).getProto());
 }
 return false;
}

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

@Override
public boolean equals(Object other) {
 if (other == null)
  return false;
 if (other.getClass().isAssignableFrom(this.getClass())) {
  return this.getProto().equals(this.getClass().cast(other).getProto());
 }
 return false;
}

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

@Override
public int compareTo(Datum datum) {
 if (datum.kind() == TajoDataTypes.Type.PROTOBUF) {
  return value.equals(((ProtobufDatum)datum).get()) ? 0 : -1;
 } else {
  return -1;
 }
}

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

@Override
public int compareTo(Datum datum) {
 if (datum.type() == TajoDataTypes.Type.PROTOBUF) {
  return value.equals(((ProtobufDatum)datum).get()) ? 0 : -1;
 } else {
  return -1;
 }
}

代码示例来源:origin: stackoverflow.com

for (Message msg : msgs) {
   if (!msg.equals(msgs_array)) {
     Log.d("Chat", "Message : " + msg.getTitle() + ": "
         + msg.getMessage());
         msgs_array.add(msg);
     newMsg = true;
     Log.d("Chat", "New Message ? " + newMsg);
   }
 }

代码示例来源:origin: FoundationDB/fdb-record-layer

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  FDBStoredRecord<?> that = (FDBStoredRecord<?>) o;
  if (!primaryKey.equals(that.primaryKey)) {
    return false;
  }
  if (!recordType.getName().equals(that.recordType.getName())) {
    return false;
  }
  if (!record.equals(that.record)) {
    return false;
  }
  if (recordVersion == null && that.recordVersion != null || recordVersion != null && !recordVersion.equals(that.recordVersion)) {
    return false;
  }
  return this.keyCount == that.keyCount && this.keySize == that.keySize && this.valueSize == that.valueSize
      && this.split == that.split && this.versionedInline == that.versionedInline;
}

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

public <T extends Message> List<T> convertJsonArrayToProto(
  T prototype, JsonNode array, String extensionName) {
 List<T> messages = Lists.newArrayList();
 for (JsonNode messageNode : array) {
  try {
   String nodeJson = new ObjectMapper().writeValueAsString(messageNode);
   T message = convertJsonToProto(prototype, nodeJson, extensionName);
   if (!message.equals(prototype)) {
    messages.add(message);
   }
  } catch (IOException ex) {
   // Should not be possible to throw in newer versions of ObjectMapper.
   diagCollector.addDiag(
     Diag.error(
       new SimpleLocation(extensionName),
       String.format(
         "The extension %s does not match the schema. It should be a %s. Please refer "
           + "to documentation of the extension.",
         extensionName, prototype.getDescriptorForType().getName())));
  }
 }
 return messages;
}

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

public <T extends Message> List<T> convertJsonArrayToProto(
  T prototype, JsonNode array, String extensionName) {
 List<T> messages = Lists.newArrayList();
 for (JsonNode messageNode : array) {
  try {
   String nodeJson = new ObjectMapper().writeValueAsString(messageNode);
   T message = convertJsonToProto(prototype, nodeJson, extensionName);
   if (!message.equals(prototype)) {
    messages.add(message);
   }
  } catch (IOException ex) {
   // Should not be possible to throw in newer versions of ObjectMapper.
   diagCollector.addDiag(
     Diag.error(
       new SimpleLocation(extensionName),
       String.format(
         "The extension %s does not match the schema. It should be a %s. Please refer "
           + "to documentation of the extension.",
         extensionName, prototype.getDescriptorForType().getName())));
  }
 }
 return messages;
}

代码示例来源:origin: com.google.template/soy

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 if (o instanceof LogStatement) {
  LogStatement that = (LogStatement) o;
  return (this.id == that.id())
     && ((this.data == null) ? (that.data() == null) : this.data.equals(that.data()))
     && (this.logOnly == that.logOnly());
 }
 return false;
}

相关文章