public class TypeHelper
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static double |
castToDouble(java.lang.Object o)
Attempts to create a
double number out of an object. |
static int |
castToInteger(java.lang.Object o)
Attempts to create an
int number out of an object. |
static boolean |
valueEquals(java.lang.Object o1,
java.lang.Object o2)
Compares two objects based on their values.
|
public static boolean valueEquals(java.lang.Object o1,
java.lang.Object o2)
o1 and o2 are both strings,
they are equal if their text is equalo1 and o2 are both numbers,
they are equal if their conversion into a double
returns the same valueequals() method is invokedo1 - The first objecto2 - The second objecttrue or false according to the rules
mentioned abovepublic static double castToDouble(java.lang.Object o)
double number out of an object.
o is a Number, it returns o.doubleValue()o is a String, it is parsed as a double; 0 is
returned if the parsing failso is anything else, 0 is returnedo - The objectpublic static int castToInteger(java.lang.Object o)
int number out of an object.
o is a Number, it returns o.intValue()o is a String, it is parsed as an int; 0 is
returned if the parsing failso is anything else, 0 is returnedo - The objectCopyright © Sylvain HallĂ©. All Rights Reserved.