List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.smallchill.core.toolbox.Func.java
/** * ?<br>/*from w w w . j a v a2 s .c om*/ * ????<br> * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2) * * @param obj1 * 1 * @param obj2 * 2 * @return ? */ public static boolean equals(Object obj1, Object obj2) { return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null); }
From source file:Main.java
/** * <p>Finds the last index of the given object in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than * the array length will search from the end of the array.</p> * /*from w w w .ja v a2 s.c o m*/ * @param array the array to traverse for looking for the object, may be <code>null</code> * @param objectToFind the object to find, may be <code>null</code> * @param startIndex the start index to travers backwards from * @return the last index of the object within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(Object[] array, Object objectToFind, int startIndex) { if (array == null) { return -1; } if (startIndex < 0) { return -1; } else if (startIndex >= array.length) { startIndex = array.length - 1; } if (objectToFind == null) { for (int i = startIndex; i >= 0; i--) { if (array[i] == null) { return i; } } } else { for (int i = startIndex; i >= 0; i--) { if (objectToFind.equals(array[i])) { return i; } } } return -1; }
From source file:cn.fql.utility.ClassUtility.java
/** * compare property of two object//from w w w. j a v a 2 s . co m * * @param obj1 object instance * @param obj2 object instance * @param propertyName name of property which is required to be compared * @return boolean value */ public static boolean comparePropertyEqual(Object obj1, Object obj2, String propertyName) { Object value1 = getPropertyValue(obj1, propertyName); Object value2 = getPropertyValue(obj2, propertyName); boolean isEqual = true; if (value1 != null ^ value2 != null) { isEqual = false; } else { if (value1 != null) { isEqual = value1.equals(value2); } } return isEqual; }
From source file:io.github.moosbusch.lumpi.util.LumpiUtil.java
public static String getNamespaceIdForBean(Object bean, org.apache.pivot.collections.Map<String, Object> namespace) { if (bean == null) { throw new NullPointerException(); }/*from w ww . j av a 2s . com*/ for (String id : namespace) { Object obj = Objects.requireNonNull(namespace.get(id)); if (obj.equals(bean)) { return id; } } return null; }
From source file:nz.co.senanque.validationengine.ValidationUtils.java
public static boolean equals(final Object o, final Object o1) { if (o == null && o1 == null) { return true; }/*from w w w .j a v a 2s . c o m*/ if (o == null || o1 == null) { return false; } if (o instanceof Number && o1 instanceof Number) { return ((Number) o).doubleValue() == ((Number) o1).doubleValue(); } return o.equals(o1); }
From source file:com.discovery.darchrow.lang.ObjectUtil.java
/** * ?? <br>/*www . j a va 2 s.com*/ * ?,object.equals(object2)?true * * @param object * object * @param object2 * object2 * @return ?,object.equals(object2)?true */ public static final boolean equalsNotNull(Object object, Object object2) { if (Validator.isNotNullOrEmpty(object) && Validator.isNotNullOrEmpty(object2)) { return object.equals(object2); } return false; }
From source file:com.softmotions.commons.bean.BeanUtils.java
/** * Checks if the given objects are equal. * * @param a The object to compare with object b. * @param b The object to compare with object a. * @param caseSensitive Tells whether or not to compare string values case sensitive. * This parameter is only respected, in case a is a <code>java.lang.String</code> instance. * @return true if the objects are equal or are both null. *//*from www. j a v a 2 s . c o m*/ public static boolean equals(Object a, Object b, boolean caseSensitive) { if ((a == null) || (b == null)) { return a == b; } if (a instanceof String) { return caseSensitive ? StringUtils.equalsIgnoreCase(a.toString(), b.toString()) : StringUtils.equals(a.toString(), b.toString()); } return a.equals(b); }
From source file:com.shenit.commons.utils.ValidationUtils.java
/** * ???/*from w ww. ja v a 2 s. c om*/ * * @param val1 * 1 * @param range * * @return */ public static boolean in(Object val1, Object... range) { if (val1 == null || range == null || range.length < 1) return false; for (Object aVal : range) { if (val1.equals(aVal)) return true; } return false; }
From source file:io.ecarf.core.utils.Utils.java
/** * Wait until two values become equal//from w ww . ja v a 2 s . c o m * @param value1 * @param value2 */ public static void waitForEquality(Object value1, Object value2, int seconds) { while (!value1.equals(value2)) { ApiUtils.block(seconds); } }
From source file:com.shenit.commons.utils.DataUtils.java
/** * Make a object to boolean//from ww w.jav a2 s .c o m * @param apply * @return */ public static boolean toBoolean(Object obj) { if (obj == null) return false; String str = obj.toString(); if (obj instanceof Number) { //special handle for number object, 0 is false, and other s are true return !obj.equals(0); } else if (StringUtils.isNumeric(str)) { //no matter how, just compare with 0 return Long.parseLong(str) != 0; } else { return new Boolean(obj.toString()); } }