Example usage for java.lang Number equals

List of usage examples for java.lang Number equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

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

Usage

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a required int parameter.//from ww w  .ja va  2s  .  co  m
 *
 * @param  request   the servlet request
 * @param  paramName the parameter name
 *
 * @return the value of the parsed parameter
 *
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected int parseRequiredIntParameter(HttpServletRequest request, String paramName) {
    int value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.intValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }

    return value;
}

From source file:org.rhq.enterprise.gui.common.servlet.ParameterizedServlet.java

/**
 * Parse a required long parameter./*ww  w  . ja  va 2s . co  m*/
 *
 * @param  request   the servlet request
 * @param  paramName the parameter name
 *
 * @return the value of the parsed parameter
 *
 * @throws IllegalArgumentException if the parameter didn't exist
 */
protected long parseRequiredLongParameter(HttpServletRequest request, String paramName) {
    long value;
    String param = request.getParameter(paramName);
    if (null != param) {
        Number n = NumberUtil.stringAsNumber(param);
        if (n.equals(NumberUtil.NaN)) {
            throw invalidParamErr(paramName, param);
        } else {
            value = n.longValue();
        }
    } else {
        throw requiredParamErr(paramName);
    }

    return value;
}

From source file:org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1.java

private void updateVertexProperty(AtlasVertex vertex, String propertyName, Date newValue) {
    if (newValue != null) {
        Number currValue = vertex.getProperty(propertyName, Number.class);

        if (currValue == null || !currValue.equals(newValue.getTime())) {
            vertex.setProperty(propertyName, newValue.getTime());
        }/*from   w w  w  . j ava 2s .  c om*/
    }
}

From source file:org.kalypso.ogc.gml.featureview.control.SpinnerFeatureControl.java

protected ICommand getChanges() {
    final Feature feature = getFeature();

    final Number newData = getCurrentValue();

    final IPropertyType pt = getFeatureTypeProperty();
    final Object oldData = feature.getProperty(pt);

    // nur ndern, wenn sich wirklich was gendert hat
    if (newData == null && oldData != null || newData != null && !newData.equals(oldData))
        return new ChangeFeatureCommand(feature, pt, newData);

    return null;//  www  . j a  va2s. c  om
}

From source file:org.jfree.data.category.CategoryToPieDataset.java

/**
 * Tests this dataset for equality with an arbitrary object, returning
 * <code>true</code> if <code>obj</code> is a dataset containing the same
 * keys and values in the same order as this dataset.
 *
 * @param obj  the object to test (<code>null</code> permitted).
 *
 * @return A boolean.//from  ww w  . j  av  a2s . c  o  m
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof PieDataset)) {
        return false;
    }
    PieDataset that = (PieDataset) obj;
    int count = getItemCount();
    if (that.getItemCount() != count) {
        return false;
    }
    for (int i = 0; i < count; i++) {
        Comparable k1 = getKey(i);
        Comparable k2 = that.getKey(i);
        if (!k1.equals(k2)) {
            return false;
        }

        Number v1 = getValue(i);
        Number v2 = that.getValue(i);
        if (v1 == null) {
            if (v2 != null) {
                return false;
            }
        } else {
            if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;
}

From source file:org.eclipse.wb.internal.os.macosx.OSSupportMacOSXCocoa.java

private Image makeShotAwt0(Display display, Object component, int width, int height) {
    GC gc = null;/*from   w  ww.  jav  a  2 s.  c  om*/
    try {
        Image image = new Image(display, width, height);
        gc = new GC(image);
        H context = getID(gc, "handle");
        Number peerId = getComponentPeerId(component);
        Number parentId = findParentComponentPeerId(component);
        if (peerId == null || parentId == null || peerId.equals(parentId)) {
            return null;
        }
        _makeShot(peerId, parentId, context);
        return image;
    } catch (Throwable e) {
        // ignore and return null;
    } finally {
        if (gc != null) {
            gc.dispose();
        }
    }
    return null;
}

From source file:org.jfree.data.general.DefaultPieDataset.java

/**
 * Tests if this object is equal to another.
 *
 * @param obj  the other object./*  w  w w  .j av a  2 s .  com*/
 *
 * @return A boolean.
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }

    if (!(obj instanceof PieDataset)) {
        return false;
    }
    PieDataset that = (PieDataset) obj;
    int count = getItemCount();
    if (that.getItemCount() != count) {
        return false;
    }

    for (int i = 0; i < count; i++) {
        Comparable k1 = getKey(i);
        Comparable k2 = that.getKey(i);
        if (!k1.equals(k2)) {
            return false;
        }

        Number v1 = getValue(i);
        Number v2 = that.getValue(i);
        if (v1 == null) {
            if (v2 != null) {
                return false;
            }
        } else {
            if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;

}

From source file:org.jfree.data.pie.DefaultPieDataset.java

/**
 * Tests if this object is equal to another.
 *
 * @param obj  the other object.//from  w w  w  .  j a  v a 2s  .c  om
 *
 * @return A boolean.
 */
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }

    if (!(obj instanceof PieDataset)) {
        return false;
    }
    PieDataset that = (PieDataset) obj;
    int count = getItemCount();
    if (that.getItemCount() != count) {
        return false;
    }

    for (int i = 0; i < count; i++) {
        Comparable k1 = getKey(i);
        Comparable k2 = that.getKey(i);
        if (!k1.equals(k2)) {
            return false;
        }

        Number v1 = getValue(i);
        Number v2 = that.getValue(i);
        if (v1 == null) {
            if (v2 != null) {
                return false;
            }
        } else {
            if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;

}

From source file:org.jfree.data.category.DefaultCategoryDataset.java

/**
 * Tests this dataset for equality with an arbitrary object.
 *
 * @param obj  the object (<code>null</code> permitted).
 *
 * @return A boolean.//ww  w  .  j a va 2 s.  c o  m
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof CategoryDataset)) {
        return false;
    }
    CategoryDataset that = (CategoryDataset) obj;
    if (!getRowKeys().equals(that.getRowKeys())) {
        return false;
    }
    if (!getColumnKeys().equals(that.getColumnKeys())) {
        return false;
    }
    int rowCount = getRowCount();
    int colCount = getColumnCount();
    for (int r = 0; r < rowCount; r++) {
        for (int c = 0; c < colCount; c++) {
            Number v1 = getValue(r, c);
            Number v2 = that.getValue(r, c);
            if (v1 == null) {
                if (v2 != null) {
                    return false;
                }
            } else if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;
}

From source file:org.jfree.data.DefaultKeyedValues.java

/**
 * Tests if this object is equal to another.
 *
 * @param obj  the object (<code>null</code> permitted).
 *
 * @return A boolean.//from ww w .  ja  v  a 2 s .  c om
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }

    if (!(obj instanceof KeyedValues)) {
        return false;
    }

    KeyedValues that = (KeyedValues) obj;
    int count = getItemCount();
    if (count != that.getItemCount()) {
        return false;
    }

    for (int i = 0; i < count; i++) {
        Comparable k1 = getKey(i);
        Comparable k2 = that.getKey(i);
        if (!k1.equals(k2)) {
            return false;
        }
        Number v1 = getValue(i);
        Number v2 = that.getValue(i);
        if (v1 == null) {
            if (v2 != null) {
                return false;
            }
        } else {
            if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;
}