litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package org.litesoft.core.typeutils;
import java.util.*;
@SuppressWarnings("Convert2Diamond")
public class Sets
{
public static <T> HashSet<T> newHashSet()
{
return new HashSet<T>();
}
public static <T> HashSet<T> newHashSet( int zInitialSize )
{
return new HashSet<T>( Math.max( 1, zInitialSize ) );
}
@SuppressWarnings("unchecked")
public static <T> HashSet<T> newHashSet( T... pInitialEntries )
{
HashSet<T> zSet = newHashSet();
add( zSet, pInitialEntries );
return zSet;
}
public static <T> Set<T> empty()
{
return Collections.emptySet();
}
public static <T> Set<T> copy( Set<T> pSet )
{
Set<T> zCopy = newHashSet();
zCopy.addAll( deNull( pSet ) );
return zCopy;
}
@SuppressWarnings("unchecked")
public static <T> void add( Set<T> pSet, T... pToAdd )
{
if ( pToAdd != null )
{
for ( T zT : pToAdd )
{
if ( zT != null )
{
pSet.add( zT );
}
}
}
}
public static <T> Set<T> deNull( Set<T> pToCheck )
{
if ( pToCheck == null )
{
pToCheck = empty();
}
return pToCheck;
}
public static boolean isNullOrEmpty( Set<?> pToCheck )
{
return (pToCheck == null || pToCheck.isEmpty());
}
public static boolean isNotNullOrEmpty( Set<?> pToCheck )
{
return (pToCheck != null && !pToCheck.isEmpty());
}
public static void assertNotNullNotEmpty( String pErrorMessage, Set<?> pToAssert )
throws IllegalArgumentException
{
if ( isNullOrEmpty( pToAssert ) )
{
Strings.errorNullOrEmpty( pErrorMessage, "Collection" );
}
}
}
|
Revision |
Author |
Commited |
Message |
936
|
GeorgeS
|
Sun 01 Jun, 2014 20:19:38 +0000 |
|