Example usage for java.lang Object equals

List of usage examples for java.lang Object equals

Introduction

In this page you can find the example usage for java.lang Object equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.sample.common.util.AssertUtil.java

/**
 * Solleva una @link(IllegalArgumentException) con message message in caso di object non null
 * /* ww  w  .  j  a va 2 s.  c o  m*/
 * @param object
 * @param message
 */
public static void assertEquals(Object obj1, Object obj2, String message) {
    if (!obj1.equals(obj2)) {
        throw new IllegalArgumentException(message);
    }
}

From source file:Main.java

/**
 * <p>//from  w  ww . j av a 2  s .  c  o m
 * Gets the index of a targetted element in a specified array.
 * </p>
 *
 * @param target the element to search
 * @param elements the array
 * @return the index of the element in the array, -1 if not found
 */
public static int indexOf(final Object target, final Object... elements) {
    for (int i = 0; i < elements.length; i++) {
        if (target.equals(elements[i])) {
            return i;
        }
    }

    return -1;
}

From source file:OrderedMap.java

private static boolean eq(Object o1, Object o2) {
    return (o1 == null ? o2 == null : o1.equals(o2));
}

From source file:Main.java

private static boolean sparselyEqualLists(List expected, List actual) {
    if (expected.size() != actual.size()) {
        return false;
    }/*from   w ww. j  a  va 2  s.c  om*/
    Iterator actualIterator = actual.iterator();
    for (Iterator expectedIterator = expected.iterator(); expectedIterator.hasNext();) {
        Object expectedItem = expectedIterator.next();
        Object actualItem = actualIterator.next();
        if (expectedItem != null && !expectedItem.equals(actualItem)) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

public static Object decode(Object expr, Object... pat) {
    for (int i = 0; i < pat.length; i++) {
        if (i + 1 >= pat.length) //default
            return pat[i];

        if (expr.equals(pat[i++]))
            return pat[i];
    }// w  ww. jav  a  2 s  .c om
    return null;
}

From source file:Main.java

public static boolean equals(Object o1, Object o2) {
    if (o1 == o2) {
        return true;
    }//from   ww w .j a v  a 2s .  c om
    if (o1 == null || o2 == null) {
        return false;
    }
    return o1.equals(o2);
}

From source file:es.caib.zkib.jxpath.ri.model.dynabeans.DynaBeanPointer.java

/**
 * Learn whether two objects are == || .equals().
 * @param o1 first object//from w  w w.j a  v  a  2 s  .  c o m
 * @param o2 second object
 * @return boolean
 */
private static boolean equalObjects(Object o1, Object o2) {
    return o1 == o2 || o1 != null && o1.equals(o2);
}

From source file:Main.java

/**
 * Returns <code>true</code> if both lists are the same?
 *
 * @param set1//from w w w .ja  v a2s.  c o m
 * @param set2
 * @return
 */
@SuppressWarnings("ObjectEquality")
public static boolean same(final Set set1, final Set set2) {

    if (set1 == null || set2 == null) {
        return false;
    }
    if (set1.size() != set2.size()) {
        return false;
    }
    if (set1 == set2) {
        return true;
    }
    final Iterator iter1 = set1.iterator();
    final Iterator iter2 = set2.iterator();
    while (iter1.hasNext()) {
        final Object o1 = iter1.next();
        final Object o2 = iter2.next();
        if (!o1.equals(o2)) {
            return false;
        }
    }
    return true;
}

From source file:cc.pinel.mangue.storage.AbstractStorage.java

/**
 * Finds the manga JSON object from the array
 * based on the manga id provided.//from   w  w  w .ja  va 2  s.co  m
 * 
 * @param jsonMangas the array
 * @param mangaId the manga id
 * @return the manga, if found
 */
protected static JSONObject findManga(JSONArray jsonMangas, String mangaId) {
    for (int i = 0; i < jsonMangas.size(); i++) {
        JSONObject jsonManga = (JSONObject) jsonMangas.get(i);
        Object id = jsonManga == null ? null : jsonManga.get("id");
        if (id.equals(mangaId))
            return jsonManga;
    }
    return null;
}

From source file:Main.java

public static boolean equals(Object one, Object another) {
    if (one == another) // one == another  
        return true;
    if (one == null || another == null)
        return false;
    return one.equals(another);
}