org.geotools.util.Utilities.deepEquals()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(117)

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

Utilities.deepEquals介绍

[英]Convenience method for testing two objects for equality. One or both objects may be null. If both are non-null and are arrays, then every array elements will be compared.

This method may be useful when the objects may or may not be array. If they are known to be arrays, consider using Arrays#deepEquals(Object[],Object[]) or one of its primitive counter-part instead.

Rules for choosing an equals or deepEquals method

  • If both objects are declared as Object[] (not anything else like String[]), consider using Arrays#deepEquals(Object[],Object[]) except if it is known that the array elements can never be other arrays.
  • Otherwise if both objects are arrays (e.g. Expression[], String[], int[], etc.), use Arrays#equals(Object[],Object[]). This rule is applicable to arrays of primitive type too, since Arrays.equals is overriden with primitive counter-parts.
  • Otherwise if at least one object is anything else than Object (e.g. String, Expression, etc.), use #equals(Object,Object). Using this deepEquals method would be an overkill since there is no chance that String or Expression could be an array.
  • Otherwise if both objects are declared exactly as Object type and it is known that they could be arrays, only then invoke this deepEquals method. In such case, make sure that the hash code is computed using #deepHashCode for consistency.
    [中]测试两个物体是否相等的简便方法。一个或两个对象可能为空。如果两者都是非空数组,则将比较每个数组元素。
    当对象可能是数组,也可能不是数组时,此方法可能很有用。如果已知它们是数组,则考虑使用数组ηDePiqQuales(object [],object [])或其原始计数器部分之一。
    选择equals或deepEquals方法的规则
    *如果**两个对象都被声明为对象[](不是任何其他的像String []),除了使用数组的元素永远不能是其他数组之外,还要考虑使用数组ηDePiqQual[Obj[],Obj[])。
    *否则,如果两个对象都是数组(例如表达式[]、字符串[]、int[]等),则使用数组#equals(对象[]、对象[])。这个规则也适用于基元类型的数组,因为数组。equals被原始计数器部分覆盖。
    否则,如果至少有一个对象不是对象(例如字符串、表达式等),请使用#equals(对象、对象)。由于字符串或表达式不可能是数组,使用这个deepEquals方法将是一种过分的杀伤力。
    否则,如果两个
    对象都被声明为完全相同的对象类型,并且已知它们可能是数组,那么只调用这个deepEquals方法。在这种情况下,请确保使用#deepHashCode计算哈希代码以确保一致性。

代码示例

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

@Override
public boolean equals(Object obj) {
  if (this == obj) return true;
  if (!(obj instanceof TiePoint)) return false;
  final TiePoint that = (TiePoint) obj;
  if (Utilities.deepEquals(this.values, that.values)) return true;
  return false;
}

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

public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof PropertyImpl)) {
    return false;
  }
  PropertyImpl other = (PropertyImpl) obj;
  if (!Utilities.equals(descriptor, other.descriptor)) return false;
  if (!Utilities.deepEquals(value, other.value)) return false;
  return true;
}

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

public boolean equals(Object o) {
  if (!(o instanceof AttributeDescriptorImpl)) return false;
  AttributeDescriptorImpl d = (AttributeDescriptorImpl) o;
  return super.equals(o) && Utilities.deepEquals(defaultValue, d.defaultValue);
}

代码示例来源:origin: org.geotools/gt-coverage

@Override
public boolean equals(Object obj) {
  if(this==obj)
    return true;
  if(!(obj instanceof TiePoint))
    return false;
  final TiePoint that= (TiePoint) obj;
  if(Utilities.deepEquals(this.values, that.values))
    return true;
  return false;
}

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

/**
 * Override of equals.
 *
 * @param other the object to be tested for equality.
 * @return whether other is equal to this attribute Type.
 */
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Attribute)) {
    return false;
  }
  Attribute other = (Attribute) obj;
  if (!Utilities.equals(getDescriptor(), other.getDescriptor())) {
    return false;
  }
  if (!Utilities.deepEquals(getValue(), other.getValue())) {
    return false;
  }
  return Utilities.equals(getIdentifier(), other.getIdentifier());
}

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

return Utilities.deepEquals(value, this.value);

代码示例来源:origin: org.geotools/gt-main

public boolean equals(Object o){
  if(!(o instanceof AttributeDescriptorImpl))
    return false;
  
  AttributeDescriptorImpl d = (AttributeDescriptorImpl)o;

  return super.equals(o) && Utilities.deepEquals( defaultValue, d.defaultValue );
}

代码示例来源:origin: org.geotools/gt-main

public boolean equals(Object obj) {
  if ( this == obj ) {
    return true;
  }
  
  if (!(obj instanceof PropertyImpl)) {
    return false;
  }
  PropertyImpl other = (PropertyImpl) obj;
  if (!Utilities.equals(descriptor, other.descriptor))
    return false;
  if (!Utilities.deepEquals(value, other.value))
    return false;   

  return true;
}

代码示例来源:origin: org.geotools/gt-imagemosaic

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (!(obj instanceof CatalogBuilderConfiguration))
    return false;
  final CatalogBuilderConfiguration that = (CatalogBuilderConfiguration) obj;
  if (this.absolute != that.absolute)
    return false;
  if (this.caching != that.caching)
    return false;
  if (this.recursive != that.recursive)
    return false;
  if (this.footprintManagement != that.footprintManagement)
    return false;
  if (!(this.indexName == null && that.indexName == null)
      && !this.indexName.equals(that.indexName))
    return false;
  if (!(this.locationAttribute == null && that.locationAttribute == null)
      && !this.locationAttribute.equals(that.locationAttribute))
    return false;
  if (!(this.rootMosaicDirectory == null && that.rootMosaicDirectory == null)
      && !this.rootMosaicDirectory.equals(that.rootMosaicDirectory))
    return false;
  if (!Utilities.deepEquals(this.indexingDirectories,
      that.indexingDirectories))
    return false;
  return true;
}

代码示例来源:origin: locationtech/geowave

@Override
 public void write() throws IOException {
  if (live == null) {
   LOGGER.error("Unable to process transaction " + transaction.toString());
   throw new IOException("No current feature to write");
  }

  if (original == null) {
   transaction.add(live.getID(), live);
  } else if (!Utilities.deepEquals(live, original)) {
   transaction.modify(live.getID(), original, live);
  }
  original = null;
  live = null;
 }
}

代码示例来源:origin: org.geotools/gt-main

/**
 * Override of equals.
 * 
 * @param other
 *            the object to be tested for equality.
 * 
 * @return whether other is equal to this attribute Type.
 */
public boolean equals(Object obj) {
  if ( this == obj ) {
    return true;
  }
  
  if (!(obj instanceof Attribute)) {
    return false;
  }
  Attribute other = (Attribute) obj;
  if (!Utilities.equals(getDescriptor(), other.getDescriptor())){
    return false;
  }
  if (!Utilities.deepEquals(getValue(), other.getValue())){
    return false;   
  }
  return Utilities.equals( getIdentifier(), other.getIdentifier());
}

代码示例来源:origin: locationtech/geogig

/**
 * Override of equals.
 * 
 * @param other the object to be tested for equality.
 * 
 * @return whether other is equal to this attribute Type.
 */
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Attribute)) {
    return false;
  }
  Attribute other = (Attribute) obj;
  if (!Utilities.equals(getDescriptor(), other.getDescriptor())) {
    return false;
  }
  if (!Utilities.deepEquals(getValue(), other.getValue())) {
    return false;
  }
  return Utilities.equals(getIdentifier(), other.getIdentifier());
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

/**
 * Override of equals.
 * 
 * @param other the object to be tested for equality.
 * 
 * @return whether other is equal to this attribute Type.
 */
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Attribute)) {
    return false;
  }
  Attribute other = (Attribute) obj;
  if (!Utilities.equals(getDescriptor(), other.getDescriptor())) {
    return false;
  }
  if (!Utilities.deepEquals(getValue(), other.getValue())) {
    return false;
  }
  return Utilities.equals(getIdentifier(), other.getIdentifier());
}

代码示例来源:origin: org.geogit/geogit-core

/**
 * Override of equals.
 * 
 * @param other the object to be tested for equality.
 * 
 * @return whether other is equal to this attribute Type.
 */
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Attribute)) {
    return false;
  }
  Attribute other = (Attribute) obj;
  if (!Utilities.equals(getDescriptor(), other.getDescriptor())) {
    return false;
  }
  if (!Utilities.deepEquals(getValue(), other.getValue())) {
    return false;
  }
  return Utilities.equals(getIdentifier(), other.getIdentifier());
}

代码示例来源:origin: org.geotools/gt-main

return Utilities.deepEquals(value, this.value);

相关文章