List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.mawujun.util.AnnotationUtils.java
/** * Helper method for checking whether two objects of the given type are * equal. This method is used to compare the parameters of two annotation * instances.//from w ww . ja va 2 s .c o m * * @param type the type of the objects to be compared * @param o1 the first object * @param o2 the second object * @return a flag whether these objects are equal */ private static boolean memberEquals(Class<?> type, Object o1, Object o2) { if (o1 == o2) { return true; } if (o1 == null || o2 == null) { return false; } if (type.isArray()) { return arrayMemberEquals(type.getComponentType(), o1, o2); } if (type.isAnnotation()) { return equals((Annotation) o1, (Annotation) o2); } return o1.equals(o2); }
From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java
/** * ??????????????//from w ww .ja va 2 s . co m * ??{@link java.lang.Object#equals(Object)}??? * @param suspect * @param target * @return ?????true */ public static boolean equalsTo(Object suspect, Object target) { if (suspect == null) return true; return suspect.equals(target); }
From source file:net.sf.jrf.domain.PersistentObjectDynaClass.java
/** Transfers the properties from the bean to the <code>PersistentObject</code> in a * "stateful" or "stateless" manner.//w w w . j a va 2s . c o m * @param bean <code>DynaBean</code> instance to process. * @param aPO <code>PersistentObject</code> to update. * @param stateful if <code>true</code>, <code>PersistentObject</code> argument represents * the state of the object before manipulation of a bean. */ private static void beanToPersistentObject(PersistentObjectDynaClass c, DynaBean bean, PersistentObject aPO, boolean stateful) { DynaProperty[] props = c.getDynaProperties(); PersistentState state = (stateful ? aPO.getPersistentState() : (PersistentState) bean.get("persistentState")); int count = 0; // Respect deleted state, if necessary. if (state.isDeletedPersistentState()) { if (!stateful) aPO.forceDeletedPersistentState(); return; } for (int i = 0; i < props.length; i++) { PersistentObjectDynaProperty cp; if ((cp = PersistentObjectDynaProperty.getPOProperty(props[i])) != null && !cp.getName().equals("persistentState") && !cp.isIndexed() && !cp.isMapped()) { Object beanValue = bean.get(cp.getName()); if (!stateful) { if (LOG.isDebugEnabled()) { LOG.debug("Stateless copy for po: " + aPO + ": setting bean value for " + cp.getName() + " to [" + beanValue + "]"); } cp.set(aPO, beanValue); } else { // Stateful update -- check current values. boolean changed = true; // Do not touch primary key, "write once" // or optimistic lock values for existing // records. if (state.isCurrentPersistentState() && (cp.isWriteOnce() || cp.isOptimisticLock())) { changed = false; } else { Object poValue = cp.get(aPO); if (LOG.isDebugEnabled()) { LOG.debug("Stateful copy for po: " + aPO + ": setting bean value for " + cp.getName() + " to " + beanValue + " if not equal to " + poValue); } if (poValue != null && !poValue.equals(beanValue)) changed = true; else if (beanValue != null && !beanValue.equals(poValue)) changed = true; else changed = false; } if (changed) { count++; cp.set(aPO, beanValue); } } } } // Set State accordingly. if (stateful) { if (state.isNewPersistentState()) aPO.forceNewPersistentState(); else if (state.isCurrentPersistentState()) { if (count > 0) aPO.forceModifiedPersistentState(); else aPO.forceCurrentPersistentState(); } } else { // Stateless. if (state.isNewPersistentState()) { aPO.forceNewPersistentState(); } else if (state.isCurrentPersistentState()) { aPO.forceModifiedPersistentState(); } } if (LOG.isDebugEnabled()) LOG.debug("copy bean to PO is complete: object is now: " + aPO); }
From source file:com.all.shared.sync.SyncGenericConverter.java
private static Object readValue(String attributeName, Class<?> clazz, Map<String, Object> map) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Object value = map.get(attributeName); if (value != null && !clazz.equals(value.getClass())) { if (clazz.equals(Date.class) && StringUtils.isNumeric(value.toString())) { return new Date(new Long(value.toString())); }//from w ww .j a v a 2 s .co m if (clazz.isEnum() && value instanceof String) { for (Object enumType : clazz.getEnumConstants()) { if (value.equals(enumType.toString())) { return enumType; } } } if (PRIMITIVES.contains(clazz)) { return clazz.getConstructor(String.class).newInstance(value.toString()); } } return value; }
From source file:com.swingtech.commons.util.ClassUtil.java
public static boolean beanContainsPropertyValue(final Object bean, final String beanPropertyName, final Object value) { Object beanValue; try {//from ww w .j av a2s .c o m beanValue = getBeanProperty(bean, beanPropertyName); } catch (final Throwable t) { return false; } return beanValue.equals(value); }
From source file:edu.mbl.jif.datasetconvert.CheckboxTreeDimensions.java
public static int indexOfChannel(Object[] array, Object objectToFind, int startIndex) { if (array == null) { return -1; }// w ww . ja v a2s . c om if (startIndex < 0) { startIndex = 0; } if (objectToFind == null) { for (int i = startIndex; i < array.length; i++) { if (array[i] == null) { return i; } } } else { for (int i = startIndex; i < array.length; i++) { if (objectToFind.equals(array[i])) { return i; } } } return -1; }
From source file:net.kamhon.ieagle.util.VoUtil.java
public static boolean isPropertySameValue(Object obj, Object obj2, String propertiesName) { try {//from w w w .j a v a 2 s . c om Object objValue = PropertyUtils.getProperty(obj, propertiesName); Object objValue2 = PropertyUtils.getProperty(obj2, propertiesName); if (objValue == null && objValue2 == null) { return true; } else if (objValue == null || objValue2 == null) { return false; } else { return objValue.equals(objValue2); } } catch (Exception ex) { throw new DataException(ex); } }
From source file:com.projity.util.ClassUtils.java
public static boolean isMultipleValue(Object value) { if (value == null) return false; return (value == LONG_MULTIPLE_VALUES || value == DOUBLE_MULTIPLE_VALUES || value == INTEGER_MULTIPLE_VALUES || value == FLOAT_MULTIPLE_VALUES || value == STRING_MULTIPLE_VALUES || value.equals(PERCENT_MULTIPLE_VALUES) || value == RATE_MULTIPLE_VALUES || value == Duration.ZERO || value == DateTime.getZeroDate()); }
From source file:com.facebook.TestUtils.java
private static boolean areEqual(final Object expected, final Object actual) { if (expected == actual) { return true; }/*from ww w . j av a 2 s .com*/ if ((expected == null) || (actual == null)) { return false; } if ((expected instanceof JSONObject) && (actual instanceof JSONObject)) { return areEqual((JSONObject) expected, (JSONObject) actual); } if ((expected instanceof JSONArray) && (actual instanceof JSONArray)) { return areEqual((JSONArray) expected, (JSONArray) actual); } return expected.equals(actual); }
From source file:net.sensemaker.snappy.SnappyUtil.java
public static boolean jsonEquals(JSONArray a, JSONArray b) { for (int i = 0; i < a.length(); i++) { Object valueA = a.get(i); Object valueB = b.get(i); if (!valueA.getClass().getName().equals(valueB.getClass().getName())) return false; if (valueA instanceof JSONObject) { if (!jsonEquals((JSONObject) valueA, (JSONObject) valueB)) return false; }// w w w . j av a2 s . com if (valueA instanceof JSONArray) { if (!jsonEquals((JSONArray) valueA, (JSONArray) valueB)) return false; } if (!valueA.equals(valueB)) return false; } return true; }