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:com.jaspersoft.studio.components.chart.model.theme.util.PadUtil.java

/**
 * Method used to set the property of a blockframe.
 *    //from  w  w w.  j av a 2  s. c  o  m
 * @param id Identifier of the property to set
 * @param value value of the property
 * @param settings LegendSettings that contains the block frame provider that will be set
 */
public static void setFramePropertyValue(Object id, Object value, LegendSettings settings) {
    if (settings == null)
        return;
    String preID = LegendSettings.PROPERTY_frame;
    if (id.equals(preID + PadUtil.FRAME_FILL)) {
        checkValidFrame(settings);
        Boolean fill = (Boolean) value;
        if (fill && !(settings.getBlockFrame() instanceof BlockBorderProvider)) {
            BlockFrameProvider currentFrame = settings.getFrame();
            BlockBorderProvider fillFrame = new BlockBorderProvider(getFrameInstets(currentFrame),
                    getPaint(currentFrame));
            settings.setFrame(fillFrame);
        }
        if (!fill && !(settings.getBlockFrame() instanceof LineBorderProvider)) {
            BlockFrameProvider currentFrame = settings.getFrame();
            LineBorderProvider fillFrame = new LineBorderProvider(getFrameInstets(currentFrame),
                    new BasicStroke(1.0f), getPaint(currentFrame));
            settings.setFrame(fillFrame);
        }
    } else if (id.equals(preID + PadUtil.FRAME_STROKE)) {
        checkValidFrame(settings);
        if (settings.getFrame() instanceof LineBorderProvider) {
            LineBorderProvider currentFrame = (LineBorderProvider) settings.getFrame();
            if (value == null)
                value = 0.0d;
            float strokeValue = ((Number) value).floatValue();
            currentFrame.setLineStroke(new BasicStroke(strokeValue));
            //need to force the refresh
            settings.setFrame(null);
            settings.setFrame(currentFrame);
        }
    } else if (id.equals(preID + FRAME_COLOR)) {
        checkValidFrame(settings);
        setFrameColor(settings.getFrame(), (PaintProvider) value, settings);
    } else if (id.equals(preID + PadUtil.PADDING_TOP) || id.equals(preID + PadUtil.PADDING_BOTTOM)
            || id.equals(preID + PadUtil.PADDING_LEFT) || id.equals(preID + PADDING_RIGHT)) {
        checkValidFrame(settings);
        RectangleInsets newInsets = setPropertyValue(id, value, settings.getFrame().getBlockFrame().getInsets(),
                preID);
        if (newInsets != null) {
            setFrameInstets(newInsets, settings.getFrame(), settings);
        }
    }
}

From source file:de.dfki.kiara.jsonrpc.JsonRpcProtocol.java

public static boolean equalIds(Object id1, Object id2) {
    if (id1 == id2) {
        return true;
    }/*from www .  ja v a  2s.  c o  m*/
    if (id1 == null || id2 == null) {
        return false;
    }

    if (isIntegral(id1) && isIntegral(id2)) {
        if (((Number) id1).longValue() == ((Number) id2).longValue()) {
            return true;
        }
    }
    return id1.equals(id2);
}

From source file:com.evolveum.midpoint.util.MiscUtil.java

public static boolean unorderedCollectionEquals(Collection a, Collection b) {
    Comparator<?> comparator = new Comparator<Object>() {
        @Override//from ww  w  .j  a v  a  2  s.co m
        public int compare(Object o1, Object o2) {
            return o1.equals(o2) ? 0 : 1;
        }
    };
    return unorderedCollectionEquals(a, b, comparator);
}

From source file:com.shenit.commons.utils.ValidationUtils.java

/**
 * check value equalization//from w  w  w.  j a  v  a2s.co m
 * @param v1
 * @param v2
 * @return
 */
public static boolean eq(Object v1, Object v2) {
    return v1 == v2 || (v1 != null && v1.equals(v2));
}

From source file:com.fsck.k9.helper.Utility.java

public static boolean arrayContains(Object[] a, Object o) {
    for (Object element : a) {
        if (element.equals(o)) {
            return true;
        }//from ww w  .ja va2 s. co m
    }
    return false;
}

From source file:Main.java

/**
 * Finds the index of the given object in the array starting at the given index.
 *
 * This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.
 *
 * A negative startIndex is treated as zero. A startIndex larger than the array
 * length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).
 * /*w w w  .j  a  va2s.  c  o  m*/
 * @param array  the array to search through for the object, may be <code>null</code>
 * @param objectToFind  the object to find, may be <code>null</code>
 * @param startIndex  the index to start searching at
 * @return the index of the object within the array starting at the index,
 *  {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input
 */
public static int indexOf(Object[] array, Object objectToFind, int startIndex) {
    if (array == null) {
        return -1;
    }
    if (startIndex < 0) {
        startIndex = 0;
    }
    if (objectToFind == null) {
        for (int i = startIndex; i < array.length; i++) {
            if (array[i] == null) {
                return i;
            }
        }
    } else {
        for (int i = startIndex; i < array.length; i++) {
            if (objectToFind.equals(array[i])) {
                return i;
            }
        }
    }
    return -1;
}

From source file:com.jaspersoft.studio.components.chart.model.theme.util.PadUtil.java

/**
 * Method used to extract a property from a block frame provider using an id of 
 * the property. If the blockframe is undefined a default value is given
 * /*from  w  w w .  j a  va  2 s  .c  o m*/
 * @param id identifier of the property
 * @param provider object from where the property is extracted
 * @return the result, can be null
 */
public static Object getBlockFrameValue(Object id, BlockFrameProvider provider) {
    if (provider == null) {
        return frameDefaultValues.get(id);
    } else {
        String preID = LegendSettings.PROPERTY_frame;
        if (id.equals(preID + PadUtil.FRAME_FILL)) {
            return !(provider instanceof LineBorderProvider);
        } else if (id.equals(preID + PadUtil.FRAME_STROKE)) {
            if (provider instanceof LineBorderProvider) {
                BasicStroke stroke = (BasicStroke) ((LineBorderProvider) provider).getLineStroke();
                return stroke != null ? stroke.getLineWidth() : null;
            } else
                return null;
        } else if (id.equals(preID + FRAME_COLOR)) {
            return getPaint(provider);
        } else {
            return getPropertyValue(id, provider.getBlockFrame().getInsets(), preID);
        }
    }
}

From source file:Main.java

/**
 * Test the equality of two object arrays.
 *
 * @param a       The first array.//from  w  w  w.j a  v a2s . com
 * @param b       The second array.
 * @param deep    True to traverse elements which are arrays.
 * @return        True if arrays are equal.
 */
public static boolean equals(final Object[] a, final Object[] b, final boolean deep) {
    if (a == b)
        return true;
    if (a == null || b == null)
        return false;
    if (a.length != b.length)
        return false;

    for (int i = 0; i < a.length; i++) {
        Object x = a[i];
        Object y = b[i];

        if (x != y)
            return false;
        if (x == null || y == null)
            return false;
        if (deep) {
            if (x instanceof Object[] && y instanceof Object[]) {
                if (!equals((Object[]) x, (Object[]) y, true))
                    return false;
            } else {
                return false;
            }
        }
        if (!x.equals(y))
            return false;
    }

    return true;
}

From source file:it.unibo.alchemist.language.protelis.util.Op2.java

private static boolean equals(final Object a, final Object b) {
    if (a == null && b == null) {
        return true;
    }//from   ww  w  .  j av  a  2s .  com
    if (a == null || b == null) {
        return false;
    }
    return a.equals(b);
}

From source file:com.doculibre.constellio.utils.EqualityUtils.java

public static boolean isEqualOrBothNullProperty(String propertyName, Object bean1, Object bean2) {
    boolean result;
    try {/*from w w w . j  a va2s  . co m*/
        Object propertyValue1 = PropertyUtils.getProperty(bean1, propertyName);
        Object propertyValue2 = PropertyUtils.getProperty(bean2, propertyName);
        if (propertyValue1 == null && propertyValue2 == null) {
            result = true;
        } else if ((propertyValue1 == null && propertyValue2 != null)
                || (propertyValue1 != null && propertyValue2 == null)) {
            result = false;
        } else {
            result = propertyValue1.equals(propertyValue2);
        }
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
    return result;
}