java.util.IdentityHashMap.equals()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(103)

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

IdentityHashMap.equals介绍

[英]Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent identical object-reference mappings. More formally, this map is equal to another map m if and only if this.entrySet().equals(m.entrySet()).

Owing to the reference-equality-based semantics of this map it is possible that the symmetry and transitivity requirements of the Object.equals contract may be violated if this map is compared to a normal map. However, the Object.equals contract is guaranteed to hold among IdentityHashMap instances.
[中]将指定对象与此映射进行相等性比较。如果给定对象也是一个映射,并且两个映射表示相同的对象引用映射,则返回true。更正式地说,这个映射等于另一个映射m,当且仅当。entrySet()。等于(m.entrySet())。
由于该映射基于引用等式的语义,因此对象的对称性和及物性要求可能会满足。如果将此映射与普通映射进行比较,则可能违反equals契约。然而,这一目标是正确的。equals契约保证在IdentityHashMap实例之间保持不变。

代码示例

代码示例来源:origin: Sable/soot

@Override
public boolean equals(Object obj) {
 if (this == obj) {
  return true;
 }
 if (obj == null) {
  return false;
 }
 if (getClass() != obj.getClass()) {
  return false;
 }
 final IdentityHashSet<?> other = (IdentityHashSet<?>) obj;
 if (delegate == null) {
  if (other.delegate != null) {
   return false;
  }
 } else if (!delegate.equals(other.delegate)) {
  return false;
 }
 return true;
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!super.equals(obj)) {
    return false;
  }
  if (!(obj instanceof Filter)) {
    return false;
  }
  final Filter other = (Filter) obj;
  if (disabled == null) {
    if (other.disabled != null) {
      return false;
    }
  } else if (!disabled.equals(other.disabled)) {
    return false;
  }
  return true;
}

代码示例来源:origin: protostuff/protostuff

return false;
else if (!identityHashMap.equals(other.identityHashMap))
  return false;
if (linkedHashMap == null)

代码示例来源:origin: protostuff/protostuff

return false;
else if (!identityHashMap.equals(other.identityHashMap))
  return false;
if (linkedHashMap == null)

代码示例来源:origin: net.sf.rubycollect4j/rubycollect4j

@Override
public boolean equals(Object o) {
 return map.equals(o);
}

代码示例来源:origin: com.google.code.findbugs/findbugs

@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!super.equals(obj)) {
    return false;
  }
  if (!(obj instanceof Filter)) {
    return false;
  }
  final Filter other = (Filter) obj;
  if (disabled == null) {
    if (other.disabled != null) {
      return false;
    }
  } else if (!disabled.equals(other.disabled)) {
    return false;
  }
  return true;
}

相关文章