public static String lispToCamel(final String pString, final boolean pFirstUpperCase) {
        if (pString == null) {
            throw new IllegalArgumentException("string == null");
        }
        if (pString.length() == 0) {
            return pString;
        }

        StringBuilder buf = null;
        int lastPos = 0;

        for (int i = 0; i < pString.length(); i++) {
            char current = pString.charAt(i);
            if (current == '-') {

                // Init buffer if necessary
                if (buf == null) {
                    buf = new StringBuilder(pString.length() - 1);// Can't be larger
                }

                // Append with upper case
                if (lastPos != 0 || pFirstUpperCase) {
                    buf.append(Character.toUpperCase(pString.charAt(lastPos)));
                    lastPos++;
                }

                buf.append(pString.substring(lastPos, i).toLowerCase());
                lastPos = i + 1;
            }
        }

        if (buf != null) {
            buf.append(Character.toUpperCase(pString.charAt(lastPos)));
            buf.append(pString.substring(lastPos + 1).toLowerCase());
            return buf.toString();
        }
        else {
            if (pFirstUpperCase && !Character.isUpperCase(pString.charAt(0))) {
                return capitalize(pString, 0);
            }
            else
            if (!pFirstUpperCase && Character.isUpperCase(pString.charAt(0))) {
                return Character.toLowerCase(pString.charAt(0)) + pString.substring(1);
            }

            return pString;
        }
    }
public static String lispToCamel ( final String pString , final boolean pFirstUpperCase ) { if ( pString == null ) { throw new IllegalArgumentException ( "string == null" ) ; } if ( pString . length ( ) == 0 ) { return pString ; } StringBuilder buf = null ; int lastPos = 0 ; for ( int i = 0 ; i < pString . length ( ) ; i ++ ) { char current = pString . charAt ( i ) ; if ( current == '-' ) { if ( buf == null ) { buf = new StringBuilder ( pString . length ( ) - 1 ) ; } if ( lastPos != 0 || pFirstUpperCase ) { buf . append ( Character . toUpperCase ( pString . charAt ( lastPos ) ) ) ; lastPos ++ ; } buf . append ( pString . substring ( lastPos , i ) . toLowerCase ( ) ) ; lastPos = i + 1 ; } } if ( buf != null ) { buf . append ( Character . toUpperCase ( pString . charAt ( lastPos ) ) ) ; buf . append ( pString . substring ( lastPos + 1 ) . toLowerCase ( ) ) ; return buf . toString ( ) ; } else { if ( pFirstUpperCase && ! Character . isUpperCase ( pString . charAt ( 0 ) ) ) { return capitalize ( pString , 0 ) ; } else if ( ! pFirstUpperCase && Character . isUpperCase ( pString . charAt ( 0 ) ) ) { return Character . toLowerCase ( pString . charAt ( 0 ) ) + pString . substring ( 1 ) ; } return pString ; } }
Converts the input string
from Lisp-style naming convention (hyphen delimitted, all lower case)
to camel-style (Java in-fix) naming convention.
Other characters in the string are left untouched.
<p/>
To create a string starting with a lower case letter
(like Java variable names, etc),
specify the {@code pFirstUpperCase} paramter to be {@code false}.
Eg.
{@code "foo" => "foo"},
{@code "foo-bar" => "fooBar"},
{@code "allreadyCamel" => "allreadyCamel"}
<p/>
To create a string starting with an upper case letter
(like Java class name, etc),
specify the {@code pFirstUpperCase} paramter to be {@code true}.
Eg.
{@code "http-request-wrapper" => "HttpRequestWrapper"}
{@code "my-45-caliber" => "My45Caliber"}
<p/>

@param pString         the lisp-style input string
@param pFirstUpperCase {@code true} if the first char should be
upper case
@return the string converted to camel-style
@throws IllegalArgumentException if {@code pString == null}
@see #camelToLisp(String)