Here you can find the source of fieldNameFromPropertyName(final String propertyName)
Parameter | Description |
---|---|
propertyName | the property name |
public static String fieldNameFromPropertyName(final String propertyName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 LegSem.//w w w .j a v a2s.com * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * LegSem - initial API and implementation ******************************************************************************/ public class Main { /** * Field names are derived from property names by lower casing the first * character. * * @param propertyName the property name * @return a valid field name or null if property name is empty */ public static String fieldNameFromPropertyName(final String propertyName) { String fieldName = null; if (propertyName != null && propertyName.length() > 0) { fieldName = propertyName.substring(0, 1).toLowerCase(); if (propertyName.length() > 1) { fieldName += propertyName.substring(1, propertyName.length()); } } return fieldName; } }