List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.thoughtworks.xstream.io.json.JsonWriterModeTest.java
private static boolean equals(Object o1, Object o2) { if (o1 == null && o2 == null) { return true; } else if ((o1 == null && o2 != null) || (o1 != null && o2 == null)) { return false; }/*from ww w . j av a2 s . co m*/ Class type = o1.getClass(); if (type != o2.getClass()) { return false; } if (type == JSONObject.class) { return equals((JSONObject) o1, (JSONObject) o2); } else if (type == JSONArray.class) { return equals((JSONArray) o1, (JSONArray) o2); } return o1.equals(o2); }
From source file:com.sammyun.plugin.PaymentPlugin.java
/** * ???//from w w w.j a va 2 s . c om * * @param sArray ??? * @return ??????? */ public static Map<String, Object> paraFilter(Map<String, Object> sArray) { Map<String, Object> result = new HashMap<String, Object>(); if (sArray == null || sArray.size() <= 0) { return result; } for (String key : sArray.keySet()) { Object value = sArray.get(key); if (value == null || value.equals("") || key.equalsIgnoreCase("sign") || key.equalsIgnoreCase("sign_type")) { continue; } result.put(key, value); } return result; }
From source file:com.bigdata.dastor.utils.FBUtilities.java
public static boolean equals(Object a, Object b) { if (a == null && b == null) return true; else if (a != null && b == null) return false; else if (a == null && b != null) return false; else/*from w ww . ja v a 2 s. c o m*/ return a.equals(b); }
From source file:dbs_project.util.Utils.java
public static boolean areObjectsEqual(Object one, Object two) { return one == two || (one != null && one.equals(two)); }
From source file:eionet.cr.web.util.JstlFunctions.java
/** * * @param arrayOrCollection/* w w w .j a v a 2 s. c om*/ * @param object * @return */ public static boolean contains(Object arrayOrCollection, Object object) { if (arrayOrCollection != null) { if (arrayOrCollection instanceof Object[]) { for (Object o : ((Object[]) arrayOrCollection)) { if (o.equals(object)) { return true; } } } else if (arrayOrCollection instanceof Collection) { for (Object o : ((Collection) arrayOrCollection)) { if (o.equals(object)) { return true; } } } } return false; }
From source file:com.mg.framework.utils.DatabaseUtils.java
/** * ? ? <code>where</code> ? EJBQL ? ? * <p> ?:/* w w w . j a v a2 s . co m*/ * <blockquote><pre> * whereText = whereText.concat(DatabaseUtils.formatEJBQLObjectRangeRestriction("cat.MarketingMargin", * restForm.getTradeTaxFrom(), restForm.getTradeTaxTo(), "taxFrom", "taxTo", paramsName, * paramsValue, false)); * </pre></blockquote> * * @param fieldName ? ? ? * @param value1 ? "" * @param value2 ? "" * @param paramName1 ? ? ? "" * @param paramName2 ? ? ? "" * @param paramsName ?? ? * @param paramsValue ?? ? * @param firstRestriction , ? <code>false</code>, * ? ?? <code>" and "</code> * @return ? ? <code>where</code> */ public static String formatEJBQLObjectRangeRestriction(final String fieldName, final Object value1, final Object value2, final String paramName1, final String paramName2, List<String> paramsName, List<Object> paramsValue, boolean firstRestriction) { String result = ""; if (value1 != null && value1.equals(value2)) { result = String.format("(%s = :%s)", fieldName, paramName1); paramsName.add(paramName1); paramsValue.add(value1); } else if (value1 != null || value2 != null) { if (value1 == null) { result = String.format("(%s <= :%s)", fieldName, paramName2); paramsName.add(paramName2); paramsValue.add(value2); } else if (value2 == null) { result = String.format("(%s >= :%s)", fieldName, paramName1); paramsName.add(paramName1); paramsValue.add(value1); } else { result = String.format("(%s between :%s and :%s)", fieldName, paramName1, paramName2); paramsName.add(paramName1); paramsValue.add(value1); paramsName.add(paramName2); paramsValue.add(value2); } } if (!result.equals("")) result = generateRestrictionPrefix(result, firstRestriction); return result; }
From source file:edu.usu.sdl.openstorefront.util.ReflectionUtil.java
/** * Check to see if two fields are different * * @param original//w w w . j a va2 s . c om * @param newField * @return True if different and false if the same */ public static boolean isFieldsDifferent(Object original, Object newField) { boolean changed = false; if (original != null && newField == null) { changed = true; } else if (original == null && newField != null) { changed = true; } else if (original != null && newField != null) { changed = !(original.equals(newField)); } return changed; }
From source file:api.resources.Laptop.java
public static Laptop newInstance(Map<String, Object> params) throws APIException { Laptop laptop = new Laptop(); Set<String> keys = params.keySet(); Iterator<String> iterator = keys.iterator(); while (iterator.hasNext()) { String key = iterator.next(); if (key.equals("title")) laptop.setId((String) params.get(key)); if (key.equals("nid")) laptop.setNid((String) params.get(key)); if (key.equals("location") && params.get(key) != null) laptop.setLocation((HashMap) params.get(key)); Object param = (Object) hashValueToParam(params.get(key)); if (param == null || param.equals("")) continue; if (key.equals("field_how_did_you_learn")) laptop.setHowDidYouLearn((String) param); if (key.equals("field_current_manager")) laptop.setCurrentManager((String) getUIDParam(param)); if (key.equals("field_model")) laptop.setModel((String) param); if (key.equals("field_cpu")) laptop.setCpu(((Integer) param).intValue()); if (key.equals("field_cpu_type")) laptop.setCpuType((String) param); if (key.equals("field_memory")) laptop.setMemory(((Integer) param).intValue()); if (key.equals("field_hard_drive integer")) laptop.setHardDrive(((Integer) param).intValue()); if (key.equals("field_current_os")) laptop.setCurrentOS((String) param); if (key.equals("field_destination")) laptop.setDestination((String) param); if (key.equals("field_501c3_recipient")) laptop.setA501c3Recip((String) param); if (key.equals("field_laptop_domain")) laptop.setLaptopDomain((String) param); if (key.equals("field_status")) laptop.setStatus((String) param); if (key.equals("field_dev_type")) laptop.setDevType((String) param); if (key.equals("field_library_notification")) laptop.setLibraryNotification((String) param); if (key.equals("field_checkedout_location")) laptop.setCheckedoutLocation((String) param); if (key.equals("field_notes")) laptop.setNotes((String) param); // field_laptop_serial_number if (key.equals("field_laptop_serial_number")) laptop.setSerialNumber((String) param); if (key.equals("field_date_received")) { try { laptop.setDateReceived(stringToDate((String) param)); } catch (Exception e) { log.error("It had a problem with the date received", e); }/* w ww. ja va2s . com*/ } if (key.equals("field_date_delivered")) { try { laptop.setDateDelivered(stringToDate((String) param)); } catch (Exception e) { log.error("It had a problem with the date delivered", e); } } if (key.equals("field_available_day")) { try { laptop.setAvailableDay(stringToDate((String) param)); } catch (Exception e) { log.error("It had a problem with the available day", e); } } if (key.equals("field_date_recycled")) { try { laptop.setDateRecycled(stringToDate((String) param)); } catch (Exception e) { log.error("It had a problem with the date recycled", e); } } } return laptop; }
From source file:com.redhat.rhn.testing.TestUtils.java
/** * Used to test the equals contract on objects. * The contract as specified by java.lang.Object states that if A.equals(B) is true * then B.equals(A) is also true. It also specifies that if A.equals(B) is true * then A.hashCode() will equals B.hashCode() * @param o1 object1//from www .j a va 2 s . c om * @param o2 object2 * @return both objects equal */ public static boolean equalTest(Object o1, Object o2) { // both null if (o1 == null && o2 == null) { return true; } // just one null if (o1 == null || o2 == null) { return false; } if (o1.equals(o2) != o2.equals(o1)) { return false; } return o1.hashCode() == o2.hashCode(); }
From source file:Main.java
/** * <p>Finds the index of the given object in the array starting at the given index.</p> * <p/>//from w w w . java 2 s. c o m * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * <p/> * <p>A negative startIndex is treated as zero. A startIndex larger than the array * length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p> * * @param array the array to search through for the object, may be <code>null</code> * @param objectToFind the object to find, may be <code>null</code> * @param startIndex the index to start searching at * @return the index of the object within the array starting at the index, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int indexOf(Object[] array, Object objectToFind, int startIndex) { if (array == null) { return INDEX_NOT_FOUND; } 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 INDEX_NOT_FOUND; }