List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:Main.java
public static boolean equal(Object a, Object b) { return a == b || (a != null && a.equals(b)); }
From source file:Main.java
/** Returns true if all elements of c match obj */ public static boolean all(Collection c, Object obj) { for (Iterator iterator = c.iterator(); iterator.hasNext();) { Object o = iterator.next(); if (!o.equals(obj)) return false; }//from w ww.ja v a 2 s . c o m return true; }
From source file:Main.java
public static boolean contains(Object[] arr, Object obj) { for (int i = 0; i < arr.length; i++) { Object object = arr[i]; if (object.equals(obj)) { return true; }/*from w w w . j av a 2 s .c om*/ } return false; }
From source file:Main.java
public static int Cardinality(Object obj, Collection coll) { if (coll == null) { throw new NullPointerException(); }/*from w w w . j av a 2 s . co m*/ if (obj == null) { throw new NullPointerException(); } for (Object o : coll) { if (o.equals(obj)) { total++; } } return total; }
From source file:Main.java
/** * Find the index of a value inside an array. If not found, or any of the param is null, return -1 * @param array The array to lookup the value (if null, return -1) * @param value The value to lookup (if null, return -1) * @return the index of the match value, or -1 is not found *///from w ww.jav a 2s . c om public static int findIndex(Object[] array, Object value) { if (array == null || value == null) { return -1; } int i = 0; for (Object obj : array) { if (obj.equals(value)) { return i; } i++; } return -1; }
From source file:Main.java
public static boolean isNullOrBlank(Object value) { if (null == value || value.equals("")) { return true; } else {// w w w . ja v a 2s .com return false; } }
From source file:Main.java
public static boolean isEquals(Object a, Object b) { return (a == null) ? (b == null) : a.equals(b); }
From source file:Main.java
public static boolean remove(Collection collection, Object object) { boolean removed = false; Iterator it = collection.iterator(); while (it.hasNext()) { Object o = it.next(); if (o.equals(object)) { removed = true;//from w ww . j a v a 2 s . c o m it.remove(); break; } } return removed; }
From source file:Main.java
/** * Null-safe equivalent of {@code a.equals(b)}. * * @see java.util.Objects#equals/*from w w w . j a va2s. c o m*/ */ public static boolean bothNullOrEqual(Object a, Object b) { return a == null ? b == null : a.equals(b); }
From source file:Main.java
public static boolean equals(Object a, Object b) { return (a == b) || (a != null && a.equals(b)); }