01: /*
02: * User: Michael Rettig
03: * Date: Sep 21, 2002
04: * Time: 9:15:47 PM
05: */
06: package net.sourceforge.jaxor.util;
07:
08: import java.util.Set;
09: import java.util.HashSet;
10:
11: public class ObjectUtils {
12: public static boolean equals(Object obj, Object obj2) {
13: if (obj == null && obj2 == null)
14: return true;
15: if (obj == null)
16: return false;
17: if (obj2 == null)
18: return false;
19: return obj.equals(obj2);
20: }
21:
22: public Long toObject(long l) {
23: return new Long(l);
24: }
25:
26: public Integer toObject(int i) {
27: return new Integer(i);
28: }
29:
30: public Float toObject(float f) {
31: return new Float(f);
32: }
33:
34: public Boolean toObject(boolean b) {
35: return new Boolean(b);
36: }
37:
38: public Byte toObject(byte b) {
39: return new Byte(b);
40: }
41:
42: public Short toObject(short s) {
43: return new Short(s);
44: }
45:
46: public Double toObject(double d) {
47: return new Double(d);
48: }
49:
50: private static final Set PRIMITIVES_SET = new HashSet();
51: static {
52: PRIMITIVES_SET.add("int");
53: PRIMITIVES_SET.add("boolean");
54: PRIMITIVES_SET.add("byte");
55: PRIMITIVES_SET.add("short");
56: PRIMITIVES_SET.add("long");
57: PRIMITIVES_SET.add("float");
58: PRIMITIVES_SET.add("double");
59: }
60:
61: public static boolean isPrimitive(String type) {
62: return PRIMITIVES_SET.contains(type);
63: }
64:
65: public static boolean hasValue(String keyword) {
66: return keyword != null && !keyword.trim().equals("");
67: }
68: }
|