org.apache.sis.util.Utilities类的使用及代码示例

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

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

Utilities介绍

[英]Static methods for object comparisons in different ways (deeply, approximately, etc).
[中]以不同方式(深度、近似等)进行对象比较的静态方法。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-referencing

/**
 * Returns {@code true} if a candidate found by {@code IdentifiedObjectFinder} should be considered equals to the
 * requested object. This method invokes the {@code equals(…)} method on the {@code candidate} argument instead
 * than on the user-specified {@code object} on the assumption that implementations coming from the factory are
 * more reliable than user-specified objects.
 */
private boolean match(final IdentifiedObject candidate, final IdentifiedObject object) {
  return Utilities.deepEquals(candidate, object, ignoreAxes ? ComparisonMode.ALLOW_VARIANT : COMPARISON_MODE);
}

代码示例来源:origin: Geomatys/geotoolkit

return Utilities.equalsApproximatively(object1, object2);

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns a hash code value for this international text.
 *
 * @return a hash code value for this international text.
 */
@Override
public final int hashCode() {
  return getClass().hashCode() ^ (key + 31*Utilities.deepHashCode(arguments)) ^ (int) serialVersionUID;
}

代码示例来源:origin: org.apache.sis.core/sis-utility

assert isNotDebug(mode) : "object" + (object1 == null ? '1' : '2') + " is null";
return false;
  final Map.Entry<?,?> e1 = (Map.Entry<?,?>) object1;
  final Map.Entry<?,?> e2 = (Map.Entry<?,?>) object2;
  return deepEquals(e1.getKey(),   e2.getKey(),   mode) &&
      deepEquals(e1.getValue(), e2.getValue(), mode);
assert isNotDebug(mode) : mismatchedType(Map.Entry.class, object2);
return false;
  return equals(((Map<?,?>) object1).entrySet(),
         ((Map<?,?>) object2).entrySet(), mode);
assert isNotDebug(mode) : mismatchedType(Map.class, object2);
return false;
  return equals((Collection<?>) object1,
         (Collection<?>) object2, mode);
assert isNotDebug(mode) : mismatchedType(Collection.class, object2);
return false;
  assert isNotDebug(mode) : mismatchedType(Object[].class, object2);
  return false;
final Object[] array2 = (Object[]) object2;
if (array1 instanceof LenientComparable[]) {
  return equals((LenientComparable[]) array1, array2, mode);

代码示例来源:origin: org.apache.sis.core/sis-referencing

/**
 * If the authority defines an object equal, ignoring metadata, to the given object, returns that authority object.
 * Otherwise returns the given object unchanged. We do not invoke this method for user-supplied CRS, but only for
 * CRS or other objects created by {@code CoordinateOperationRegistry} as intermediate step.
 */
final <T extends IdentifiedObject> T toAuthorityDefinition(final Class<T> type, final T object) throws FactoryException {
  if (codeFinder != null) {
    codeFinder.setIgnoringAxes(false);
    final IdentifiedObject candidate = codeFinder.findSingleton(object);
    codeFinder.setIgnoringAxes(true);
    if (Utilities.equalsIgnoreMetadata(object, candidate)) {
      return type.cast(candidate);
    }
  }
  return object;
}

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

/**
 * If the authority defines an object equal, ignoring metadata, to the given object, returns that authority object.
 * Otherwise returns the given object unchanged. We do not invoke this method for user-supplied CRS, but only for
 * CRS or other objects created by {@code CoordinateOperationRegistry} as intermediate step.
 */
final <T extends IdentifiedObject> T toAuthorityDefinition(final Class<T> type, final T object) throws FactoryException {
  if (codeFinder != null) {
    codeFinder.setIgnoringAxes(false);
    final IdentifiedObject candidate = codeFinder.findSingleton(object);
    codeFinder.setIgnoringAxes(true);
    if (Utilities.equalsIgnoreMetadata(object, candidate)) {
      return type.cast(candidate);
    }
  }
  return object;
}

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

assert isNotDebug(mode) : ((object1 != null) ? object1.getClass()
             : (object2 != null) ? object2.getClass()
             : Object.class).getSimpleName() + " #" + (object1 == null ? '1' : '2') + " is null";
  final Map.Entry<?,?> e1 = (Map.Entry<?,?>) object1;
  final Map.Entry<?,?> e2 = (Map.Entry<?,?>) object2;
  return deepEquals(e1.getKey(),   e2.getKey(),   mode) &&
      deepEquals(e1.getValue(), e2.getValue(), mode);
assert isNotDebug(mode) : mismatchedType(Map.Entry.class, object2);
return false;
  return equals(((Map<?,?>) object1).entrySet(),
         ((Map<?,?>) object2).entrySet(), mode);
assert isNotDebug(mode) : mismatchedType(Map.class, object2);
return false;
  return equals((Collection<?>) object1,
         (Collection<?>) object2, mode);
assert isNotDebug(mode) : mismatchedType(Collection.class, object2);
return false;
  assert isNotDebug(mode) : mismatchedType(Object[].class, object2);
  return false;
final Object[] array2 = (Object[]) object2;
if (array1 instanceof LenientComparable[]) {

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
   * Compares this converter with the given object for equality, optionally ignoring rounding errors.
   */
  @Override
  public boolean equals(final Object other, final ComparisonMode mode) {
    if (other instanceof ConcatenatedConverter) {
      final ConcatenatedConverter o = (ConcatenatedConverter) other;
      return Utilities.deepEquals(c1, o.c1, mode) &&
          Utilities.deepEquals(c2, o.c2, mode);
    }
    return false;
  }
}

代码示例来源:origin: org.apache.sis.core/sis-referencing

final Datum d = components.get(i).getDatum();
for (int j=n; --j >= 0;) {
  if (Utilities.equalsIgnoreMetadata(d, datum[j])) {
    System.arraycopy(datum, j+1, datum, j, --n - j);    // Remove the datum from the list.
    continue next;

代码示例来源:origin: org.apache.sis.core/sis-referencing

final SingleCRS crsA = authoritative.next();
final SingleCRS crsG = given.next();
if (!Utilities.equalsApproximatively(crsA, crsG)) {
  if (crsA instanceof GeneralDerivedCRS && crsG instanceof GeneralDerivedCRS) {
    final Conversion cnvA = ((GeneralDerivedCRS) crsA).getConversionFromBase();
    final Conversion cnvG = ((GeneralDerivedCRS) crsG).getConversionFromBase();
    if (!Utilities.equalsApproximatively(cnvA, cnvG)) {
      return Utilities.equalsApproximatively(cnvA.getMethod(), cnvG.getMethod()) ? CONVERSION : METHOD;
  if (!Utilities.equalsApproximatively(crsA.getCoordinateSystem(), crsG.getCoordinateSystem())) {
    return CS;
  if (!Utilities.equalsApproximatively(datumA, datumG)) {
    if ((datumA instanceof GeodeticDatum) && (datumG instanceof GeodeticDatum) &&
      !Utilities.equalsApproximatively(((GeodeticDatum) datumA).getPrimeMeridian(),
                       ((GeodeticDatum) datumG).getPrimeMeridian()))

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

/**
 * Returns a hash code value for this international text.
 *
 * @return a hash code value for this international text.
 */
@Override
public final int hashCode() {
  return getClass().hashCode() ^ (key + 31*Utilities.deepHashCode(arguments)) ^ (int) serialVersionUID;
}

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

/**
 * Returns {@code true} if a candidate found by {@code IdentifiedObjectFinder} should be considered equals to the
 * requested object. This method invokes the {@code equals(…)} method on the {@code candidate} argument instead
 * than on the user-specified {@code object} on the assumption that implementations coming from the factory are
 * more reliable than user-specified objects.
 */
private boolean match(final IdentifiedObject candidate, final IdentifiedObject object) {
  return Utilities.deepEquals(candidate, object, ignoreAxes ? ComparisonMode.ALLOW_VARIANT : COMPARISON_MODE);
}

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

final Datum d = components.get(i).getDatum();
for (int j=n; --j >= 0;) {
  if (Utilities.equalsIgnoreMetadata(d, datum[j])) {
    System.arraycopy(datum, j+1, datum, j, --n - j);    // Remove the datum from the list.
    continue next;

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

final SingleCRS crsA = authoritative.next();
final SingleCRS crsG = given.next();
if (!Utilities.equalsApproximatively(crsA, crsG)) {
  if (crsA instanceof GeneralDerivedCRS && crsG instanceof GeneralDerivedCRS) {
    final Conversion cnvA = ((GeneralDerivedCRS) crsA).getConversionFromBase();
    final Conversion cnvG = ((GeneralDerivedCRS) crsG).getConversionFromBase();
    if (!Utilities.equalsApproximatively(cnvA, cnvG)) {
      return Utilities.equalsApproximatively(cnvA.getMethod(), cnvG.getMethod()) ? CONVERSION : METHOD;
  if (!Utilities.equalsApproximatively(crsA.getCoordinateSystem(), crsG.getCoordinateSystem())) {
    return CS;
  if (!Utilities.equalsApproximatively(datumA, datumG)) {
    if ((datumA instanceof GeodeticDatum) && (datumG instanceof GeodeticDatum) &&
      !Utilities.equalsApproximatively(((GeodeticDatum) datumA).getPrimeMeridian(),
                       ((GeodeticDatum) datumG).getPrimeMeridian()))

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns the hash code value for the given key.
 *
 * @param  key  the key (can not be null).
 */
final int keyHashCode(final Object key) {
  switch (comparisonMode) {
    case IDENTITY:    return System.identityHashCode(key);
    case EQUALS:      return key.hashCode();
    case DEEP_EQUALS: return Utilities.deepHashCode(key);
    default: throw new AssertionError(comparisonMode);
  }
}

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

/**
   * Compares this converter with the given object for equality, optionally ignoring rounding errors.
   */
  @Override
  public boolean equals(final Object other, final ComparisonMode mode) {
    if (other instanceof ConcatenatedConverter) {
      final ConcatenatedConverter o = (ConcatenatedConverter) other;
      return Utilities.deepEquals(c1, o.c1, mode) &&
          Utilities.deepEquals(c2, o.c2, mode);
    }
    return false;
  }
}

代码示例来源:origin: Geomatys/geotoolkit

defaultCRS = Utilities.equalsIgnoreMetadata(sourceCRS, targetCRS) ? null : sourceCRS;
factory = FactoryFinder.getCoordinateOperationFactory(hints);

代码示例来源:origin: org.apache.sis.core/sis-referencing

if (Utilities.equalsApproximatively(sourceCRS, crs = operation.getSourceCRS())) sourceCRS = crs;
if (Utilities.equalsApproximatively(targetCRS, crs = operation.getTargetCRS())) targetCRS = crs;
final Map<String,Object> properties = new HashMap<String,Object>(derivedFrom(operation));

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

/**
 * Returns the hash code value for the given key.
 *
 * @param  key  the key (can not be null).
 */
final int keyHashCode(final Object key) {
  switch (comparisonMode) {
    case IDENTITY:    return System.identityHashCode(key);
    case EQUALS:      return key.hashCode();
    case DEEP_EQUALS: return Utilities.deepHashCode(key);
    default: throw new AssertionError(comparisonMode);
  }
}

代码示例来源:origin: org.apache.sis.core/sis-referencing

/**
 * Returns {@code true} if at least one of the specified CRS is null, or both CRS are equals.
 * This special processing for {@code null} values is different from the usual contract of an
 * {@code equals} method, but allow to handle the case where the CRS is unknown.
 *
 * <p>Note that in debug mode (to be used in assertions only), the comparisons are actually a
 * bit more relax than just "ignoring metadata", since some rounding errors are tolerated.</p>
 */
static boolean equalsIgnoreMetadata(final CoordinateReferenceSystem crs1,
                  final CoordinateReferenceSystem crs2, final boolean debug)
{
  return (crs1 == null) || (crs2 == null) || Utilities.deepEquals(crs1, crs2,
      debug ? ComparisonMode.DEBUG : ComparisonMode.IGNORE_METADATA);
}

相关文章