List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:Main.java
public static final <T> int indexOf(T[] array, T obj) { if (array != null) { for (int i = 0; i < array.length; ++i) { Object o = array[i]; if (o != null) { if (o.equals(obj)) { return i; }/*from ww w .ja v a 2 s.c om*/ } else if (obj == null) { return i; } } } return -1; }
From source file:Main.java
/** * Search whether any object in 'objects' array does equal 'searchForObject'. * @param objects can be null, and can contain null values * @param searchForObject can be null//from w w w . j a v a 2 s. c om * @return true if searchForObject is found in 'objects' */ public static boolean containsObject(Object objects[], Object searchForObject) { if (objects == null) { return false; } for (Object object : objects) { boolean found = object == null ? searchForObject == null : object.equals(searchForObject); if (found) { return true; } } return false; }
From source file:Main.java
public static int search(Object[] objects, Object element) { int e = -1;//from w w w. j av a 2s. co m for (int w = 0; w < objects.length; w++) { if (!element.equals(objects[w])) { continue; } else { e = w; break; } } return e; }
From source file:fi.vm.sade.osoitepalvelu.kooste.common.util.EqualsHelper.java
public static boolean areEquals(Object x, Object y) { return x == y || (x != null && y != null && x.equals(y)); }
From source file:Main.java
public static boolean equals(Object[] x, Object[] y) { if (x == y) { return true; }// w w w.j a va2 s . c o m if (x.length != y.length) { return false; } int index = 0; for (int len = x.length; index < len; index++) { Object valX = x[index]; Object valY = y[index]; if (!valX.equals(valY)) { return false; } } return true; }
From source file:Main.java
/** * Convenience method for retrieving the UIDefault for a single property * of a particular class./* ww w . j ava2 s. c o m*/ * * @param clazz the class of interest * @param property the property to query * @return the UIDefault property, or null if not found */ public static Object getUIDefaultOfClass(Class<?> clazz, String property) { Object retVal = null; UIDefaults defaults = getUIDefaultsOfClass(clazz); List<Object> listKeys = Collections.list(defaults.keys()); for (Object key : listKeys) { if (key.equals(property)) { return defaults.get(key); } if (key.toString().equalsIgnoreCase(property)) { retVal = defaults.get(key); } } return retVal; }
From source file:com.thoughtworks.go.util.ObjectUtil.java
public static boolean equal(Object one, Object other) { if (one != null ? !one.equals(other) : other != null) { return false; }//www . j a v a 2 s .c om return true; }
From source file:Main.java
public static int count(Collection<?> c, Object o) { int count = 0; if (c != null && o != null) { for (Object element : c) { if (o.equals(element)) count++;/*from w w w . j ava 2 s . c o m*/ } } return count; }
From source file:Main.java
public static boolean equals(List x, List y) { if (x == y) { return true; }/*from ww w. j a v a 2s. c o m*/ if (x.size() != y.size()) { return false; } int index = 0; for (int len = x.size(); index < len; index++) { Object valX = x.get(index); Object valY = y.get(index); if (!valX.equals(valY)) { return false; } } return true; }
From source file:Main.java
/** * Check if two objects are equal./*from www. j ava2 s . co m*/ * * @param obj1 first object to compare, may be {@code null} * @param obj2 second object to compare, may be {@code null} * @return {@code true} if the objects are equal or both null */ public static boolean equals(final Object obj1, final Object obj2) { return obj1 == null ? obj2 == null : obj1.equals(obj2); }