List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:ColorUtils.java
public static boolean equals(Object expectedColor, Color actual) { if (expectedColor instanceof Color) { return expectedColor.equals(actual); } else if (expectedColor instanceof String) { return equals((String) expectedColor, actual); }//from w w w.j av a 2 s . c om throw new IllegalArgumentException(UNEXPECTED_COLOR_CLASS); }
From source file:com.kappaware.logtrawler.Utils.java
static public boolean isEquals(Object o1, Object o2) { if (o1 == null) { return o2 == null; } else {// w ww. j av a 2 s . com return o1.equals(o2); } }
From source file:Main.java
/** * Merge the list of data to main list by list of key * * @param lstMain Main list// www . j a va2s. c om * @param lstData List of data. Every item is also a list. * @param lstKey List of key */ public static void mergeData(List lstMain, List lstData, List lstKey) { if (lstMain == null || lstData == null || lstData.size() == 0 || lstKey == null || lstKey.size() == 0) { return; } for (int index1 = 0, n = lstMain.size(); index1 < n; index1++) { Map mapMain = (Map) lstMain.get(index1); Map keyValue = new HashMap(); for (int index2 = 0, m = lstKey.size(); index2 < m; index2++) { Object key = lstKey.get(index2); keyValue.put(key, mapMain.get(key)); } for (int index2 = 0, m = lstData.size(); index2 < m; index2++) { List lstChild = (List) lstData.get(index2); for (int index3 = 0, s = lstChild.size(); index3 < s; index3++) { Map mapChild = (Map) lstChild.get(index3); boolean flag = true; for (int index4 = 0, t = lstKey.size(); index4 < t; index4++) { Object key = lstKey.get(index4); Object valueFromMain = keyValue.get(key); Object valueFromChild = mapChild.get(key); if ((valueFromMain != null && !valueFromMain.equals(valueFromChild)) || (valueFromMain == null && valueFromChild != null)) { flag = false; break; } } if (flag) { mapMain.putAll(mapChild); break; } } } } }
From source file:Main.java
/** * Returns the number of occurrences of <i>obj</i> in <i>col</i>. *///from w w w .java 2 s . co m public static int cardinality(Object obj, final Collection col) { int count = 0; Iterator it = col.iterator(); while (it.hasNext()) { Object elt = it.next(); if ((null == obj && null == elt) || obj.equals(elt)) { count++; } } return count; }
From source file:Main.java
private static boolean objectEquals(Object obj1, Object obj2) { if (obj1 == null && obj2 == null) { return true; }/*from w ww . j a v a 2 s . c om*/ if (obj1 == null || obj2 == null) { return false; } return obj1.equals(obj2); }
From source file:ca.uhn.fhir.util.ObjectUtil.java
public static boolean equals(Object object1, Object object2) { if (object1 == object2) { return true; }//from w ww . ja va 2 s.c o m if ((object1 == null) || (object2 == null)) { return false; } return object1.equals(object2); }
From source file:Main.java
/** * compare two object/*w w w . jav a2s.c om*/ * * @param actual * @param expected * @return <ul> * <li>if both are null, return true</li> * <li>return actual.{@link Object#equals(Object)}</li> * </ul> */ public static boolean isEquals(Object actual, Object expected) { return actual == expected || (actual == null ? expected == null : actual.equals(expected)); }
From source file:Main.java
public static boolean contains(final Object[] array, final Object value) { for (final Object item : array) { if (item == null || value == null) { if (item == value) return true; continue; }/* w w w. ja v a2 s .co m*/ if (item.equals(value)) return true; } return false; }
From source file:net.sf.zekr.common.util.CollectionUtils.java
public static Object indexOf(Collection<?> collection, String method, Object value) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {//from w w w . j a v a2s . com for (Iterator<?> iter = collection.iterator(); iter.hasNext();) { Object elem = iter.next(); Object res = elem.getClass().getMethod(method, new Class[] {}).invoke(elem, new Object[] {}); if (res.equals(value)) return elem; } return null; }
From source file:ch.ralscha.extdirectspring.util.ExtDirectSpringUtil.java
/** * Checks if two objects are equal. Returns true if both objects are null * * @param a object one//from w w w. ja v a2s . co m * @param b object two * @return true if objects are equal */ public static boolean equal(Object a, Object b) { return a == b || a != null && a.equals(b); }