List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:com.discovery.darchrow.lang.EnumUtil.java
/** * fieldName value <br>//w w w. j av a 2s . c om * * <pre> * * ?{@link HttpMethodType} ,?: * * {@code * EnumUtil.getEnumByField(HttpMethodType.class, "method", "get") * } * </pre> * * @param <E> * the element type * @param <T> * the generic type * @param enumClass * the enum class {@link HttpMethodType} * @param propertyName * ??, {@link HttpMethodType}method,javabean * @param value * post * @param ignoreCase * ?? * @return enum constant * @see com.baozun.nebulaplus.bean.BeanUtil#getProperty(Object, String) * @since 1.0.8 */ private static <E extends Enum<?>, T> E getEnumByPropertyValue(Class<E> enumClass, String propertyName, T value, boolean ignoreCase) { if (Validator.isNullOrEmpty(enumClass)) { throw new IllegalArgumentException("enumClass is null or empty!"); } if (Validator.isNullOrEmpty(propertyName)) { throw new IllegalArgumentException("the fieldName is null or empty!"); } // An enum is a kind of class // and an annotation is a kind of interface // Class ? null. E[] enumConstants = enumClass.getEnumConstants(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("enumClass:[{}],enumConstants:{}", enumClass.getCanonicalName(), JsonUtil.format(enumConstants)); } for (E e : enumConstants) { Object propertyValue = PropertyUtil.getProperty(e, propertyName); if (null == propertyValue && null == value) { return e; } if (null != propertyValue && null != value) { if (ignoreCase && propertyValue.toString().equalsIgnoreCase(value.toString())) { return e; } else if (propertyValue.equals(value)) { return e; } } } String messagePattern = "can not found the enum constants,enumClass:[{}],propertyName:[{}],value:[{}],ignoreCase:[{}]"; throw new BeanUtilException( Slf4jUtil.formatMessage(messagePattern, enumClass, propertyName, value, ignoreCase)); }
From source file:com.manning.androidhacks.hack040.util.ImageWorker.java
/** * Returns true if the current work has been canceled or if there was no work * in progress on this image view. Returns false if the work in progress deals * with the same data. The work is not stopped in that case. *//*w ww . ja v a 2 s .c o m*/ public static boolean cancelPotentialWork(Object data, ImageView imageView) { final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); if (bitmapWorkerTask != null) { final Object bitmapData = bitmapWorkerTask.data; if (bitmapData == null || !bitmapData.equals(data)) { bitmapWorkerTask.cancel(false); // we will allow currently running tasks // to continue if (BuildConfig.DEBUG) { Log.d(TAG, "cancelPotentialWork - cancelled work for " + data); } } else { // The same work is already in progress. return false; } } return true; }
From source file:org.jspringbot.keyword.expression.ELUtils.java
public static Object doMap(Object... args) { Object defaultValue = null;//from w ww. j a va 2 s. c om Queue<Object> arguments = new LinkedList<Object>(); arguments.addAll(Arrays.asList(args)); Object variable = arguments.remove(); while (!arguments.isEmpty()) { if (arguments.size() > 1) { Object variableValue = arguments.remove(); Object mapValue = arguments.remove(); if (variable.equals(variableValue)) { return mapValue; } } else { // default return arguments.remove(); } } return defaultValue; }
From source file:com.github.rwitzel.streamflyer.regex.RegexModifierTest.java
/** * Asserts that two objects are not equals. Otherwise an AssertionFailedError is thrown. *///from ww w . j a v a2s . c o m static public void assertNotEquals(Object expected, Object actual) { assertTrue(expected != actual || !expected.equals(actual)); }
From source file:com.flexive.faces.FxJsfComponentUtils.java
/** * Check if the given array contains an actual value * * @param valueArray value array//from w w w . j a v a 2s . co m * @return if an actual value is set in the array */ public static boolean containsaValue(Object valueArray) { if (null != valueArray) { int len = Array.getLength(valueArray); for (int i = 0; i < len; i++) { Object value = Array.get(valueArray, i); if (value != null && !(value.equals(FxSelectRenderer.NO_VALUE))) { return true; } } } return false; }
From source file:Main.java
/** * * @param lstSrc List/*from w w w. j av a 2s. c o m*/ * @param lstDes List * @return boolean */ //////////////////////////////////////////////////////// public static boolean isSimilar(List lstSrc, List lstDes) { if (lstSrc != lstDes) { if (lstSrc.size() != lstDes.size()) return false; for (int iIndex = 0; iIndex < lstSrc.size(); iIndex++) { Object objSrc = lstSrc.get(iIndex); Object objDes = lstDes.get(iIndex); if (objSrc == null && objDes == null) continue; if (objSrc == null) return false; if (objDes == null) return false; if (objSrc.getClass() != objDes.getClass()) return false; if (objSrc instanceof List && !isSimilar((List) objSrc, (List) objDes)) return false; if (!objSrc.equals(objDes)) return false; } } return true; }
From source file:com.feilong.commons.core.lang.EnumUtil.java
/** * fieldName value <br>/*ww w . j av a2 s. co m*/ * * <pre> * * ?{@link HttpMethodType} ,?: * * {@code * EnumUtil.getEnumByField(HttpMethodType.class, "method", "get") * } * </pre> * * @param <E> * the element type * @param <T> * the generic type * @param enumClass * the enum class {@link HttpMethodType} * @param propertyName * ??, {@link HttpMethodType}method,javabean * @param value * post * @param ignoreCase * ?? * @return enum constant * @throws IllegalArgumentException * if Validator.isNullOrEmpty(enumClass) or Validator.isNullOrEmpty(propertyName) * @throws NoSuchFieldException * ?? * @throws BeanUtilException * the bean util exception * @see com.feilong.commons.core.bean.BeanUtil#getProperty(Object, String) * @since 1.0.8 */ private static <E extends Enum<?>, T> E getEnumByPropertyValue(Class<E> enumClass, String propertyName, T value, boolean ignoreCase) throws IllegalArgumentException, NoSuchFieldException, BeanUtilException { if (Validator.isNullOrEmpty(enumClass)) { throw new IllegalArgumentException("enumClass is null or empty!"); } if (Validator.isNullOrEmpty(propertyName)) { throw new IllegalArgumentException("the fieldName is null or empty!"); } // An enum is a kind of class // and an annotation is a kind of interface // Class ? null. E[] enumConstants = enumClass.getEnumConstants(); for (E e : enumConstants) { if (log.isDebugEnabled()) { log.debug("e:{}", JsonUtil.format(e)); } Object propertyValue = PropertyUtil.getProperty(e, propertyName); if (null == propertyValue && null == value) { return e; } if (null != propertyValue && null != value) { if (ignoreCase && propertyValue.toString().equalsIgnoreCase(value.toString())) { return e; } else if (propertyValue.equals(value)) { return e; } } } throw new NoSuchFieldException("can not found the enum constants,enumClass:[" + enumClass + "],propertyName:[" + propertyName + "],value:[" + value + "],ignoreCase:[" + ignoreCase + "]"); }
From source file:eagle.log.entity.meta.EntityDefinitionManager.java
private static void checkFieldTypeForMetric(MetricDefinition md, String fieldName, Object fldCls, Map<String, Class<?>> dynamicFieldTypes) { if (md != null) { if (fldCls.equals(int[].class)) { dynamicFieldTypes.put(fieldName, int.class); return; } else if (fldCls.equals(long[].class)) { dynamicFieldTypes.put(fieldName, long.class); return; } else if (fldCls.equals(double[].class)) { dynamicFieldTypes.put(fieldName, double.class); return; }//from w w w . java2 s . c om throw new IllegalArgumentException("Fields for metric entity must be one of int[], long[] or double[]"); } }
From source file:com.paperculture.mongrel2.Handler.java
private static boolean eq(Object a, Object b) { return a == b || (a != null && a.equals(b)); }
From source file:com.hoccer.tools.TestHelper.java
public static void blockUntilEquals(String pFailMessage, long pTimeout, Object pExpected, final TestHelper.Measurement pMesurement) throws Exception { Object mesuredValue = null;/*from w w w . j av a2s. c om*/ long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < pTimeout) { mesuredValue = pMesurement.getActualValue(); if (pExpected.equals(mesuredValue)) { return; } try { Thread.sleep(20); } catch (InterruptedException e) { throw new AssertionError(e); } } throw new AssertionFailedError( pFailMessage + ": should be <" + pExpected + ">, but was <" + mesuredValue + ">"); }