List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.abssh.util.ReflectionUtils.java
/** * ??//from w w w. j ava 2 s. c o m * * @param value * ? * @param toType * */ public static Object convertValue(Object value, Class<?> toType) { if (value == null) { return null; } if (value.equals("") && toType.getName().equals("java.util.Date")) { return null; } try { DateConverter dc = new DateConverter(); dc.setUseLocaleFormat(true); dc.setPatterns(new String[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss" }); ConvertUtils.register(dc, Date.class); return ConvertUtils.convert(value, toType); } catch (Exception e) { throw convertReflectionExceptionToUnchecked(e); } }
From source file:com.redhat.rhn.frontend.action.kickstart.KickstartDetailsEditAction.java
private static void setFormValueOrDefault(DynaActionForm form, String key, Object value, Object defaultValue) { if (value == null || StringUtils.isBlank(value.toString()) || value.equals(0)) { form.set(key, defaultValue);//from w w w . java2 s .c o m } else { form.set(key, value); } }
From source file:com.dgtlrepublic.model.test.DataTest.java
@SuppressWarnings("unchecked") private static void verify(Map entry) throws Exception { String fileName = (String) entry.getOrDefault("file_name", ""); boolean ignore = (Boolean) entry.getOrDefault("ignore", false); int id = (Integer) entry.getOrDefault("id", -1); HashMap<String, Object> testCases = (HashMap<String, Object>) entry.getOrDefault("results", new HashMap<String, Object>()); if (ignore || StringUtils.isBlank(fileName) || testCases.size() == 0) { System.out.println(String.format("Ignoring [%s] : { id: %s | results: %s | explicit: %s }", fileName, id, testCases.size(), ignore)); return;// ww w . jav a 2 s. co m } System.out.println("Parsing: " + fileName); HashMap<String, Object> parseResults = (HashMap<String, Object>) DataJsonConverter.toTestCaseMap(fileName) .getOrDefault("results", null); for (Entry<String, Object> testCase : testCases.entrySet()) { Object elValue = parseResults.get(testCase.getKey()); if (elValue == null) { throw new Exception(String.format("%n[%s] Missing Element: %s [%s]", fileName, testCase.getKey(), testCase.getValue())); } else if (elValue instanceof String && !elValue.equals(testCase.getValue())) { throw new Exception(String.format("%n[%s] Incorrect Value:(%s) [%s] { required: [%s] } ", fileName, testCase.getKey(), elValue, testCase.getValue())); } else if (elValue instanceof List && !((List) elValue).containsAll((Collection<?>) testCase.getValue())) { throw new Exception(String.format("%n[%s] Incorrect List Values:(%s) [%s] { required: [%s] } ", fileName, testCase.getKey(), elValue, testCase.getValue())); } } }
From source file:com.sworddance.util.ApplicationIllegalArgumentException.java
/** * * @param originalValue/*from ww w. ja va2 s .c o m*/ * @param changedValue * @param field * @param failMessageParts * @throws ApplicationIllegalArgumentException - originalValue != null * @return true - if changedValue != null and not equal to originalValue, false if no change */ public static boolean testSetOnce(Object originalValue, Object changedValue, String field, Object... failMessageParts) { if (originalValue == changedValue || changedValue == null) { // both null or identical return false; } else if (originalValue != null) { valid(originalValue.equals(changedValue), field, ": Only allowed to set this field once. Current value='", originalValue, "' != (new)=", changedValue, " ", failMessageParts); return false; } else { return true; } }
From source file:net.minecraftforge.common.config.ConfigManager.java
private static boolean shouldReadFromVar(Property property, Object propValue, Object fieldValue) { if (!propValue.equals(fieldValue)) { if (property.hasChanged()) return false; else// w w w. ja v a 2 s . c o m return true; } return false; }
From source file:ArrayMap.java
private static boolean equal(Object o1, Object o2) { return o1 == null ? o2 == null : o1.equals(o2); }
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. * @return true if the objects are equal or are both null. *//*from w w w . j a v a2s . co m*/ public static boolean equals(Object a, Object b) { if ((a == null) || (b == null)) { return a == b; } return a.equals(b); }
From source file:com.cburch.logisim.gui.main.SelectionAttributes.java
private static LinkedHashMap<Attribute<Object>, Object> computeAttributes(Collection<Component> newSel) { LinkedHashMap<Attribute<Object>, Object> attrMap; attrMap = new LinkedHashMap<Attribute<Object>, Object>(); Iterator<Component> sit = newSel.iterator(); if (sit.hasNext()) { AttributeSet first = sit.next().getAttributeSet(); for (Attribute<?> attr : first.getAttributes()) { @SuppressWarnings("unchecked") Attribute<Object> attrObj = (Attribute<Object>) attr; attrMap.put(attrObj, first.getValue(attr)); }//from ww w . jav a 2s .com while (sit.hasNext()) { AttributeSet next = sit.next().getAttributeSet(); Iterator<Attribute<Object>> ait = attrMap.keySet().iterator(); while (ait.hasNext()) { Attribute<Object> attr = ait.next(); if (next.containsAttribute(attr)) { Object v = attrMap.get(attr); if (v != null && !v.equals(next.getValue(attr))) { attrMap.put(attr, null); } } else { ait.remove(); } } } } return attrMap; }
From source file:Utils.java
public static boolean arrayEquals(Object[] arr1, Object[] arr2) { if (arr1 == null && arr2 == null) return true; if (arr1 == null ^ arr2 == null) return false; if (!arr1.getClass().equals(arr2.getClass())) return false; if (arr1.length != arr2.length) return false; for (int i = 0; i < arr1.length; ++i) { Object obj1 = arr1[i]; Object obj2 = arr2[i];//from w ww.j av a 2 s .co m if (obj1 == null ^ obj2 == null) return false; if (obj1 != null && !obj1.equals(obj2)) return false; } return true; }
From source file:net.sf.jabref.bibtex.DuplicateCheck.java
public static double compareEntriesStrictly(BibEntry one, BibEntry two) { HashSet<String> allFields = new HashSet<>(); allFields.addAll(one.getFieldNames()); allFields.addAll(two.getFieldNames()); int score = 0; for (String field : allFields) { Object en = one.getField(field); Object to = two.getField(field); if (((en != null) && (to != null) && en.equals(to)) || ((en == null) && (to == null))) { score++;/*w w w . ja va 2s . c o m*/ } } if (score == allFields.size()) { return 1.01; // Just to make sure we can // use score>1 without // trouble. } return (double) score / allFields.size(); }