be.nille.generator.parser.ParserUtils.java Source code

Java tutorial

Introduction

Here is the source code for be.nille.generator.parser.ParserUtils.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package be.nille.generator.parser;

import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author nholvoet
 */
public class ParserUtils {

    public static String createEntityName(String string) {
        return StringUtils.capitalize(StringUtils.lowerCase(string));
    }

    public static String createFieldName(String string) {
        String[] array = string.split("\\_");
        if (array.length > 1) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < array.length; i++) {
                String s = array[i];
                if (i > 0) {
                    s = StringUtils.capitalize(s);
                }
                sb.append(s);
            }
            return sb.toString();
        }
        return string;
    }

}