Java Class Field Convert To fieldToProperty(String field)

Here you can find the source of fieldToProperty(String field)

Description

field To Property

License

Apache License

Declaration

public static String fieldToProperty(String field) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String fieldToProperty(String field) {
        if (null == field) {
            return "";
        }//from   w  ww  .j  a  v a 2  s.  com
        char[] chars = field.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            char c = chars[i];
            if (c == '_') {
                int j = i + 1;
                if (j < chars.length) {

                    sb.append(String.valueOf(chars[j]).toUpperCase());
                    i++;
                }
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}

Related

  1. fieldToColumnName(String name)
  2. fieldToGetMethod(String fieldName)
  3. fieldToPropertyName(String name)
  4. fieldToString(String name, Object value)
  5. fieldToValue(byte[] buffer, int offset, int length)