Example usage for java.lang Object equals

List of usage examples for java.lang Object equals

Introduction

In this page you can find the example usage for java.lang Object equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:net.sf.dynamicreports.report.builder.condition.UnEqualExpression.java

@Override
public Boolean evaluate(ReportParameters reportParameters) {
    Object actualValue = reportParameters.getValue(value);
    for (Object value : values) {
        if (value.equals(actualValue)) {
            return false;
        }/*www. j a v a2 s. c om*/
    }
    return true;
}

From source file:org.businessmanager.web.converter.CountryConverterOutput.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    if (value == null || value.equals("")) {
        return "";
    }//from www .j  av a2  s.co m
    if (value instanceof Country) {
        return ((Country) value).getName();
    } else if (value instanceof String) {
        Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
        Country country = openGeoDb.getCountryByCode(locale.getLanguage(), (String) value);
        if (country != null) {
            return country.getName();
        }
    }
    return "";
}

From source file:com.concursive.connect.cache.PrivateKeyCacheEntryFactory.java

public Object createEntry(Object key) throws Exception {
    if (!key.equals(1)) {
        return null;
    }// w w  w.j  a  v  a 2s. c  o m
    return context.getKey();
}

From source file:org.crazydog.util.spring.ObjectUtils.java

/**
 * Determine if the given objects are equal, returning {@code true}
 * if both are {@code null} or {@code false} if only one is
 * {@code null}./*from w  w w  .  ja va 2 s  . co m*/
 * <p>Compares arrays with {@code Arrays.equals}, performing an equality
 * check based on the array elements rather than the array reference.
 * @param o1 first Object to compare
 * @param o2 second Object to compare
 * @return whether the given objects are equal
 * @see Arrays#equals
 */
public static boolean nullSafeEquals(Object o1, Object o2) {
    if (o1 == o2) {
        return true;
    }
    if (o1 == null || o2 == null) {
        return false;
    }
    if (o1.equals(o2)) {
        return true;
    }
    if (o1.getClass().isArray() && o2.getClass().isArray()) {
        if (o1 instanceof Object[] && o2 instanceof Object[]) {
            return Arrays.equals((Object[]) o1, (Object[]) o2);
        }
        if (o1 instanceof boolean[] && o2 instanceof boolean[]) {
            return Arrays.equals((boolean[]) o1, (boolean[]) o2);
        }
        if (o1 instanceof byte[] && o2 instanceof byte[]) {
            return Arrays.equals((byte[]) o1, (byte[]) o2);
        }
        if (o1 instanceof char[] && o2 instanceof char[]) {
            return Arrays.equals((char[]) o1, (char[]) o2);
        }
        if (o1 instanceof double[] && o2 instanceof double[]) {
            return Arrays.equals((double[]) o1, (double[]) o2);
        }
        if (o1 instanceof float[] && o2 instanceof float[]) {
            return Arrays.equals((float[]) o1, (float[]) o2);
        }
        if (o1 instanceof int[] && o2 instanceof int[]) {
            return Arrays.equals((int[]) o1, (int[]) o2);
        }
        if (o1 instanceof long[] && o2 instanceof long[]) {
            return Arrays.equals((long[]) o1, (long[]) o2);
        }
        if (o1 instanceof short[] && o2 instanceof short[]) {
            return Arrays.equals((short[]) o1, (short[]) o2);
        }
    }
    return false;
}

From source file:com.kelveden.rastajax.core.raw.matchers.AnnotationValueMatcher.java

private String annotationValueToString(final Object value) {

    if (value.equals(NO_VALUE)) {
        return "annotation with no value";
    } else if (value.getClass().isArray()) {
        return "[" + StringUtils.join((String[]) value, ", ") + "]";
    } else {/*from   w w w .ja  va  2  s. co  m*/
        return "\"" + value.toString() + "\"";
    }
}

From source file:com.fujitsu.dc.core.rs.odata.AbstractODataResource.java

/**
 * ?./*from   w ww  .j a v a  2  s. c  om*/
 * @param value ??
 * @return true: false:
 */
public static boolean isDummy(Object value) {
    boolean flag = false;
    if (value.equals(DUMMY_KEY)) {
        flag = true;
    }
    return flag;
}

From source file:SoftHashMap.java

/**
 * Check for equality of non-null reference x and possibly-null y.
 * By default uses Object.equals./* w  w w  .j  a v a  2 s.c om*/
 */
static boolean eq(Object x, Object y) {
    return x == y || x.equals(y);
}

From source file:br.com.pi.converter.EntityConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object object) {
    try {//from   w  ww.j  ava2 s.c o  m
        if (object == null || object.equals("")) {
            return "";
        }
        Object value = BeanUtils.getProperty(object, "id");
        return value == null ? null : value.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.zauberlabs.commons.mom.internal.AttributesMap.java

@Override
public final Object get(final Object name) {
    return name.equals("class") ? null : transform(NaiveProperties.get(target, (String) name));
}

From source file:com.hp.ov.sdk.adaptors.StorageSystemAdaptor.java

public StorageTargetPort buildManagedPortsDto(final Object source) {
    if (null == source || source.equals("")) {
        return null;
    }//www. j  av  a2 s .c  o m
    ObjectToJsonConverter converter = ObjectToJsonConverter.getInstance();
    // convert json object to DTO, replace quotes and back slash in the file
    final StorageTargetPort storageTargetPortDto = converter.convertJsonToObject(
            StringUtil.replaceQuotesBackSlashWithQuote(
                    StringUtil.replaceQuotesAndBackSlash(converter.convertObjectToJsonString(source))),
            StorageTargetPort.class);
    return storageTargetPortDto;
}