Android Method Name Create asCamelifySetMethod(String original)

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

Description

as Camelify Set Method

Declaration

public static String asCamelifySetMethod(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 SET = "set";

    public static String asCamelifySetMethod(String original) {
        return SET + camelify(original);
    }//  w w w.j  av a 2 s . c om

    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. asCamelifyGetMethod(String original)
  2. getMethodName()
  3. getMethodName(String stmt)
  4. getMethodNameMinusGet(Method aMethod)