Android Method Name Create asCamelifyGetMethod(String original)

Here you can find the source of asCamelifyGetMethod(String original)

Description

as Camelify Get Method

Declaration

public static String asCamelifyGetMethod(String original) 

Method Source Code

//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static final String GET = "get";

    public static String asCamelifyGetMethod(String original) {
        return GET + camelify(original);
    }/*  w w w .  j av a 2  s  .c  o  m*/

    public static String camelify(String original) {
        if (original == null)
            return "";
        StringBuilder builder = new StringBuilder();
        Pattern p = Pattern.compile("[a-zA-Z0-9]+");
        Matcher m = p.matcher(original);
        String word;
        while (m.find()) {
            word = m.group();
            builder.append(capitalize(word));
        }
        return builder.toString();
    }

    private static String capitalize(String string) {
        if (string.length() > 1)
            return string.substring(0, 1).toUpperCase()
                    + string.substring(1);
        return "";
    }
}

Related

  1. asCamelifySetMethod(String original)
  2. getMethodName()
  3. getMethodName(String stmt)
  4. getMethodNameMinusGet(Method aMethod)