Subversion Repository Public Repository

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
package org.litesoft.sandbox.anywhere.util;

public class UtilsCommon
{
    public static <T> T deNull( T pValueToCheck, T pDefaultValue )
    {
        return (pValueToCheck != null) ? pValueToCheck : pDefaultValue;
    }

    public static String noEmpty( String pValue )
    {
        if ( pValue != null )
        {
            if ( (pValue = pValue.trim()).length() == 0 )
            {
                pValue = null;
            }
        }
        return pValue;
    }

    public static String assertNotEmpty( String pWhat, String pValue )
    {
        if ( null == (pValue = noEmpty( pValue )) )
        {
            throw new IllegalArgumentException( pWhat + " not allowed to be null or Empty!" );
        }
        return pValue;
    }

    /**
     * This method strips the package name off the fully qualified class name of the pObject returning just the substring
     * beginning one character beyond the last "." (And removes the wrapping Class names if Any).
     *
     * @return the substring beginning one character beyond the last "$"; null or no "$" just returns justClassName( pFullyQualifiedClassName )
     */
    public static String justSimpleName( Object pObject )
    {
        return justSimpleName( (pObject != null) ? pObject.getClass() : null );
    }

    /**
     * This method strips the package name off the fully qualified class name of the pObject returning just the substring
     * beginning one character beyond the last "." (And removes the wrapping Class names if Any).
     *
     * @return the substring beginning one character beyond the last "$"; null or no "$" just returns justClassName( pFullyQualifiedClassName )
     */
    public static String justSimpleName( Class pClass )
    {
        return justSimpleName( (pClass != null) ? pClass.getName() : null );
    }

    /**
     * This method strips the package name off a fully qualified class name returning just the substring
     * beginning one character beyond the last "." (And removes the wrapping Class names if Any).
     *
     * @return the substring beginning one character beyond the last "$"; null or no "$" just returns justClassName( pFullyQualifiedClassName )
     */
    public static String justSimpleName( String pFullyQualifiedClassName )
    {
        int zAt = (pFullyQualifiedClassName != null) ? pFullyQualifiedClassName.lastIndexOf( '$' ) : -1;
        return (zAt != -1) ? pFullyQualifiedClassName.substring( zAt + 1 ) : justClassName( pFullyQualifiedClassName );
    }

    /**
     * This method strips the package name off a fully qualified class name returning just the substring
     * beginning one character beyond the last ".".
     *
     * @return the substring beginning one character beyond the last "."; null or no "." just returns pFullyQualifiedClassName
     */
    public static String justClassName( String pFullyQualifiedClassName )
    {
        int zAt = (pFullyQualifiedClassName != null) ? pFullyQualifiedClassName.lastIndexOf( '.' ) : -1;
        return (zAt != -1) ? pFullyQualifiedClassName.substring( zAt + 1 ) : pFullyQualifiedClassName;
    }
}

Commits for litesoft/trunk/GWT_Sandbox/MultiModule/anywhere/src/org/litesoft/sandbox/anywhere/util/UtilsCommon.java

Diff revisions: vs.
Revision Author Commited Message
547 Diff Diff GeorgeS picture GeorgeS Mon 10 Oct, 2011 02:22:01 +0000
540 GeorgeS picture GeorgeS Mon 03 Oct, 2011 04:22:28 +0000