List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:io.dyn.core.handler.Handlers.java
@SuppressWarnings({ "unchecked" }) public static boolean eventsMatch(EvaluationContext evalCtx, Object lhs, Object rhs) { if (lhs == null && rhs != null) { return false; }/* w w w .jav a 2s . c o m*/ if (lhs == rhs || lhs.equals(rhs)) { return true; } if (lhs instanceof Comparable) { try { return ((Comparable) lhs).compareTo(rhs) == 0; } catch (ClassCastException e) { } } if (lhs instanceof Expression) { ScopedEvaluationContext ec = new ScopedEvaluationContext(evalCtx, rhs); Object obj = ((Expression) lhs).getValue(ec); if (obj instanceof Boolean) { return (Boolean) obj; } else { return eventsMatch(evalCtx, obj, rhs); } } if (lhs instanceof Guard) { return ((Guard) lhs).checkGuard(rhs, evalCtx); } if (rhs instanceof Guard) { return ((Guard) rhs).checkGuard(lhs, evalCtx); } if (lhs instanceof Class && rhs instanceof Class) { return ClassUtils.isAssignable((Class<?>) lhs, (Class<?>) rhs); } return false; }
From source file:WeakValueMap.java
static boolean eq(Object o1, Object o2) { return o1 == null ? o2 == null : o1.equals(o2); }
From source file:com.yahoo.egads.data.MetricMeta.java
public static boolean equals(Object o1, Object o2) { if (o1 == o2) { return true; }/*from w w w .j a v a2s .c o m*/ if (o1 == null && o2 != null) { return false; } if (o1 != null && o2 == null) { return false; } return o1.equals(o2); }
From source file:Main.java
private static boolean checkRemove(Map curMap, String[] fieldNameArray, Object[] fieldValueArray, int numFields, boolean exclude) { boolean remove = exclude; for (int i = 0; i < numFields; i++) { String fieldName = fieldNameArray[i]; Object compareObj = fieldValueArray[i]; Object curObj = curMap.get(fieldName); if (compareObj == null) { if (curObj != null) { remove = !exclude;/*from w w w. j a va 2 s. c o m*/ break; } } else { if (!compareObj.equals(curObj)) { remove = !exclude; break; } } } return remove; }
From source file:com.blackducksoftware.bdio.io.BdioReader.java
/** * Attempts to locate the specification version from a list of raw deserialized JSON objects (i.e. a list of * {@code Map<String, Object>})./*from ww w . ja v a 2 s . com*/ */ @Nullable private static String scanForSpecVersion(List<?> list) { final String fragment = BlackDuckType.BILL_OF_MATERIALS.toUri().getFragment(); for (Object o : list) { if (o instanceof Map<?, ?>) { // Check to see if the specification version is defined Object specVersion = ((Map<?, ?>) o).get(BlackDuckTerm.SPEC_VERSION.toString()); if (specVersion instanceof String) { return (String) specVersion; } // There should only be one BillOfMaterials node so if we see it, this is v0 file Object type = ((Map<?, ?>) o).get(JsonLdKeyword.TYPE.toString()); if (type.equals(fragment) || (type instanceof Collection<?> && ((Collection<?>) type).contains(BlackDuckType.BILL_OF_MATERIALS.toString()))) { break; } } } return null; }
From source file:com.quinsoft.zeidon.domains.StringDomain.java
/** * Checks to see if the application treats null strings as equal * to empty strings. If so, this will convert null to "". * * @param string//from w ww . j a va 2 s. c o m * @return */ public static String checkNullString(Application app, Object string) { if (string == null) return app.nullStringEqualsEmptyString() ? EMPTY_STRING : null; if (string.equals(EMPTY_STRING)) return EMPTY_STRING; return string.toString(); }
From source file:Utilities.java
/** * Returns <code>true</code> if the two specified objects are the same. * Returns <code>false</code> otherwise. To be considered the same, the two * references must either both be null or invoking <code>equals</code> on one * of them with the other must return <code>true</code>. *//*from w w w .j a v a 2 s. c o m*/ public static boolean areEqual(Object obj1, Object obj2) { return (obj1 == obj2) || (obj1 == null ? false : obj1.equals(obj2)); }
From source file:com.bstek.dorado.view.output.OutputUtils.java
/** * Java?JavaScript// ww w . j a v a2 s . c o m * * @param writer * Writer * @param owner * JavaScript? * @param object * Java * @param property * ??? * @param escapeValue * Java? * @throws Exception * @see #DEFAULT_VALUE */ public static void outputProperty(Writer writer, String owner, Object object, String property, Object escapeValue) throws Exception { Object value = PropertyUtils.getProperty(object, property); if (value == escapeValue || (escapeValue != null && escapeValue.equals(value))) { return; } writer.write(owner); writer.write('.'); writer.write(property); writer.write('='); if (value == null) { writer.write("null"); } else if (value instanceof String) { writer.write("\""); writer.write((String) value); writer.write("\""); } else if (value instanceof Number || value instanceof Boolean) { writer.write(value.toString()); } else if (value instanceof Date) { writer.write("new Date("); writer.write(String.valueOf(((Date) value).getTime())); writer.write(")"); } else { writer.write("\""); writer.write(value.toString()); writer.write("\""); } writer.write(";\n"); }
From source file:Main.java
private static boolean equalFields(Object paramObject1, Object paramObject2) { boolean bool1 = false; Field[] arrayOfField1 = paramObject1.getClass().getDeclaredFields(); Field[] arrayOfField2 = paramObject2.getClass().getDeclaredFields(); if (arrayOfField1.length != arrayOfField2.length) { return bool1; }//from www . j a va 2s. c o m int i = 0; try { while (true) { if (i >= arrayOfField1.length) break; Field localField1 = arrayOfField1[i]; localField1.setAccessible(true); Field localField2 = arrayOfField2[i]; localField2.setAccessible(true); Object localObject1 = localField1.get(paramObject1); Object localObject2 = localField2.get(paramObject2); if ((localObject1 == null) && (localObject2 != null)) break; if (localObject1 != null) { boolean bool2 = localObject1.equals(localObject2); if (!bool2) break; } i++; } } catch (IllegalArgumentException localIllegalArgumentException) { localIllegalArgumentException.printStackTrace(); bool1 = true; } catch (IllegalAccessException localIllegalAccessException) { label122: localIllegalAccessException.printStackTrace(); } return bool1; }
From source file:apm.common.utils.StringUtils.java
public static boolean isExistElement(Object[] arr, Object findValue) { boolean isFound = false; for (Object value : arr) { if (findValue.equals(value)) { isFound = true;/*w w w.j av a 2 s .co m*/ } break; } return isFound; }