Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
package nfe.util;
2
 
3
import java.util.Collection;
4
 
5
public final class ObjetoUtil {
6
 
7
                private ObjetoUtil(){
8
                        super();
9
                }
10
 
11
                public static Boolean equalsNull(Object object ){
12
                        return object == null;
13
                }
14
 
15
                public static Boolean differentNull(Object object){
16
                        return object != null;
17
                }
18
 
19
 
20
                /**
21
                 * Verifica se um objeto é vazio.
22
                 *
23
                 * @param obj
24
                 * @return <b>true</b> se o objeto for vazio(empty).
25
                 */
26
            public static boolean isEmpty(Object obj) {
27
                        if (obj == null)
28
                                return true;
29
                        if (obj instanceof Collection)
30
                                return ((Collection<?>) obj).size() == 0;
31
 
32
                        final String s = String.valueOf(obj).trim();
33
 
34
                        return s.length() == 0 || s.equalsIgnoreCase("null");
35
                }
36
 
37
                @SuppressWarnings("rawtypes")
38
                public static Boolean equalsNull(Collection collection){
39
                        return collection == null;
40
                }
41
 
42
                @SuppressWarnings("rawtypes")
43
                public static Boolean differentNull(Collection collection){
44
                        return collection != null;
45
                }
46
 
47
                @SuppressWarnings("rawtypes")
48
                public static Boolean isEmpty(Collection collection){
49
                        return collection.isEmpty();
50
                }
51
 
52
                @SuppressWarnings("rawtypes")
53
                public static Boolean isNotEmpty(Collection collection){
54
                        return !collection.isEmpty();
55
                }
56
 
57
}