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
81
|
package org.litesoft.core.typeutils;
import org.litesoft.core.util.*;
public class Objects
{
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
public static void assertNull( String pObjectName, Object pToBeAssert )
throws IllegalArgumentException
{
if ( pToBeAssert != null )
{
throw new IllegalArgumentException( pObjectName + ": Expected null, but was'" + pToBeAssert + "'" );
}
}
public static <T> T assertNotNull( String pObjectName, T pToBeAssert )
throws IllegalArgumentException
{
if ( pToBeAssert == null )
{
throw new IllegalArgumentException( pObjectName + UtilsCommon.NOT_ALLOWED_TO_BE_NULL );
}
return pToBeAssert;
}
public static void assertEqual( String pObjectName, Object pExpected, Object pActual )
throws IllegalArgumentException
{
if ( null == pExpected && null == pActual )
{
return;
}
if ( null != pExpected && !pExpected.equals( pActual ) )
{
throw new IllegalArgumentException( pObjectName + ": Expected '" + pExpected + "', but was '" + pActual + "'" );
}
}
public static boolean areNonArraysEqual( Object pThis, Object pThat )
{
if ( pThis == pThat ) // Same or both null
{
return true;
}
// Both CAN'T be null
return (pThis != null) ? pThis.equals( pThat ) : pThat.equals( pThis );
}
public static <T> T deNull( T pToCheck, T pDefault )
{
return (pToCheck != null) ? pToCheck : pDefault;
}
public static Object[] appendObjectArrays( Object[] pArray1, Object[] pArray2 )
{
if ( UtilsCommon.isNullOrEmpty( pArray2 ) )
{
return pArray1;
}
if ( UtilsCommon.isNullOrEmpty( pArray1 ) )
{
return pArray2;
}
Object[] joined = new Object[pArray1.length + pArray2.length];
System.arraycopy( pArray1, 0, joined, 0, pArray1.length );
System.arraycopy( pArray2, 0, joined, pArray1.length, pArray2.length );
return joined;
}
public static Object[] prependObject( Object pNewFirst, Object[] pTheRest )
{
return appendObjectArrays( new Object[]{pNewFirst}, pTheRest );
}
public static Object[] appendObject( Object[] pCurArray, Object pNewLast )
{
return appendObjectArrays( pCurArray, new Object[]{pNewLast} );
}
}
|
Revision |
Author |
Commited |
Message |
804
|
GeorgeS
|
Wed 15 Aug, 2012 12:48:51 +0000 |
|