List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.vmware.aurora.util.CommonUtil.java
/** * Check the equality of 2 objects, just like "static Object.equals()" in C#. */// w ww . j a v a 2 s . c o m public static boolean testEquals(Object obj1, Object obj2) { // first, check if they have same reference if (obj1 == obj2) { return true; } // second, check for the null case if (obj1 == null) { return (obj2 == null); } // last, check with the overridable "equals" method return obj1.equals(obj2); }
From source file:net.darkmist.clf.LogEntry.java
private static final boolean nullSafeEquals(Object a, Object b) { if (a == null) { if (b == null) return true; return false; }//from ww w . j a v a 2s . c om if (b == null) return false; return a.equals(b); }
From source file:Main.java
private static boolean listContentsEquals(Iterable<?> l1, Iterable<?> l2) { Iterator<?> iter1 = l1.iterator(); Iterator<?> iter2 = l2.iterator(); while (iter1.hasNext()) { if (!iter2.hasNext()) { return false; }//from w w w . j a va 2 s .c o m Object e1 = iter1.next(); Object e2 = iter2.next(); if ((e1 == l1 && (e2 == l1 || e2 == l2)) || (e1 == l2 && (e2 == l1 || e2 == l2))) { // handle case where list contains itself - don't overflow stack continue; } if (e1 == null ? e2 != null : !e1.equals(e2)) { return false; } } if (iter2.hasNext()) { return false; } return true; }
From source file:com.moz.fiji.schema.util.JsonEntityIdParser.java
/** * Create JsonEntityIdParser from a JSON node. * * @param node is the JSON representation of the formatted entity_id. * @param layout of the table in which the entity id belongs. * If null, then long components may not be recognized. * @return a properly constructed JsonEntityIdParser. * @throws IOException if JsonEntityIdParser can not be properly constructed. *///from w ww . jav a2 s . c om public static JsonEntityIdParser create(final JsonNode node, final FijiTableLayout layout) throws IOException { RowKeyFormat2 format = getRKF2(layout); if (node.isArray()) { final Object[] components = new Object[node.size()]; boolean wildCarded = false; for (int i = 0; i < node.size(); i++) { final Object component = getNodeValue(node.get(i)); if (component.equals(WildcardSingleton.INSTANCE)) { wildCarded = true; components[i] = null; } else if (null != format && ComponentType.LONG == format.getComponents().get(i).getType()) { components[i] = ((Number) component).longValue(); } else { components[i] = component; } } return new JsonEntityIdParser(wildCarded, layout, components); } else { // Disallow non-arrays. throw new IllegalArgumentException( "Provide components wrapped as a JSON array or provide the row key."); } }
From source file:com.cburch.logisim.gui.main.SelectionAttributes.java
private static boolean isSame(LinkedHashMap<Attribute<Object>, Object> attrMap, Attribute<?>[] oldAttrs, Object[] oldValues) {/*from w w w.jav a2s. c o m*/ if (oldAttrs.length != attrMap.size()) { return false; } else { int j = -1; for (Map.Entry<Attribute<Object>, Object> entry : attrMap.entrySet()) { j++; Attribute<Object> a = entry.getKey(); if (!oldAttrs[j].equals(a) || j >= oldValues.length) return false; Object ov = oldValues[j]; Object nv = entry.getValue(); if (ov == null ? nv != null : !ov.equals(nv)) return false; } return true; } }
From source file:com.zenoss.zenpacks.zenjmx.call.Utility.java
/** * Returns true if the two objects are both null or are equal to * each other//from www . ja va 2 s .c o m */ public static boolean equals(Object obj1, Object obj2) { if ((obj1 == null) && (obj2 == null)) { return true; } if ((obj1 == null) && (obj2 != null)) { return false; } if ((obj1 != null) && (obj2 == null)) { return false; } return obj1.equals(obj2); }
From source file:mml.handler.json.Dialect.java
private static boolean compareArrays(JSONArray a1, JSONArray a2) { boolean res = true; if (a1.size() == a2.size()) { for (int i = 0; i < a1.size(); i++) { Object o1 = a1.get(i); Object o2 = a2.get(i); if (o1 != null && o2 != null && o1.getClass().equals(o2.getClass())) { if (o1 instanceof JSONObject) res = compareObjects((JSONObject) o1, (JSONObject) o2); else if (o1 instanceof Number) res = o1.equals(o2); else if (o1 instanceof String) res = o1.equals(o2); else if (o1 instanceof JSONArray) res = compareArrays((JSONArray) o1, (JSONArray) o2); else res = false;// w w w . j a v a 2 s . co m } else res = false; } } else res = false; return res; }
From source file:Main.java
/** * A comprehensive isEqual method that handles nulls and arrays safely. * * @param value//from w w w .j a v a 2 s . c o m * Object * @param otherValue * Object * @return boolean * @deprecated {@link Objects#deepEquals(Object, Object)} */ @Deprecated @SuppressWarnings("PMD.CompareObjectsWithEquals") public static boolean areEqual(Object value, Object otherValue) { if (value == otherValue) { return true; } if (value == null) { return false; } if (otherValue == null) { return false; } if (value.getClass().getComponentType() != null) { return arraysAreEqual(value, otherValue); } return value.equals(otherValue); }
From source file:com.webarch.common.lang.StringSeriesTools.java
/** * 2?// w w w.ja v a2s . c o m * @param ob1 1 * @param ob2 2 * @return true/false */ public static boolean equalObject(Object ob1,Object ob2){ return !(ob1==null||ob2==null)&&ob1.equals(ob2); }
From source file:com.jaspersoft.studio.components.chart.model.theme.util.PadUtil.java
public static Object getPropertyValue(Object id, RectangleInsets ri, String preID) { if (ri == null) ri = PadUtil.RECTANGLE_INSETS;//from w ww .java 2 s . c om if (id.equals(preID + PadUtil.PADDING_TOP)) return ri.getTop(); if (id.equals(preID + PadUtil.PADDING_BOTTOM)) return ri.getBottom(); if (id.equals(preID + PadUtil.PADDING_LEFT)) return ri.getLeft(); if (id.equals(preID + PadUtil.PADDING_RIGHT)) return ri.getRight(); return null; }