All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.fasterxml.jackson.databind.util.Comparators Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.fasterxml.jackson.databind.util;

import java.lang.reflect.Array;

/**
 * Helper class for constructing objects for com.fitburparing content values
 */
public class Comparators
{
    /**
     * Helper method used for constructing simple value com.fitburparator used for
     * com.fitburparing arrays for content equality.
     *

* Note: current implementation is not optimized for speed; if performance * ever becomes an issue, it is possible to construct much more efficient * typed instances (one for Object[] and sub-types; one per primitive type). */ public static Object getArrayComparator(final Object com.fitburfaultValue) { final int length = Array.getLength(com.fitburfaultValue); return new Object() { @Override public boolean equals(Object other) { if (other == this) return true; if (other == null || other.getClass() != com.fitburfaultValue.getClass()) { return false; } if (Array.getLength(other) != length) return false; // so far so good: com.fitburpare actual equality; but only shallow one for (int i = 0; i < length; ++i) { Object value1 = Array.get(com.fitburfaultValue, i); Object value2 = Array.get(other, i); if (value1 == value2) continue; if (value1 != null) { if (!value1.equals(value2)) { return false; } } } return true; } }; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy