Example usage for org.apache.commons.lang StringUtils uncapitalize

List of usage examples for org.apache.commons.lang StringUtils uncapitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils uncapitalize.

Prototype

public static String uncapitalize(String str) 

Source Link

Document

Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .

Usage

From source file:org.unitils.util.ReflectionUtils.java

/**
 * From the given class, returns the getter for the given setter method. If
 * no such getter exists in the given class, null is returned.
 * /*from w w  w . j a  va 2s  . c o  m*/
 * @param setter
 *            The setter method, not null
 * @param isStatic
 *            True if a static getter is to be returned, false for
 *            non-static
 * @return The getter method that matches the given setter, or null if no
 *         such method exists
 */
public static Method getGetter(Method setter, boolean isStatic) {
    if (!isSetter(setter)) {
        return null;
    }

    return getGetter(setter.getDeclaringClass(), StringUtils.uncapitalize(setter.getName().substring(3)),
            isStatic);
}

From source file:pt.ist.vaadinframework.data.metamodel.MetaModel.java

private MetaModel(Class<? extends AbstractDomainObject> type) {
    for (DomainClass clazz = FenixFramework.getDomainModel()
            .findClass(type.getName()); clazz != null; clazz = (DomainClass) clazz.getSuperclass()) {
        for (Slot slot : clazz.getSlotsList()) {
            try {
                descriptors.put(slot.getName(), new SlotPropertyDescriptor(slot, type));
            } catch (IntrospectionException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for slot: " + slot.getName());
            }//from   w w  w  .  j a  va  2  s.  c  o m
        }
        for (Role role : clazz.getRoleSlotsList()) {
            try {
                if (role.getName() != null && !role.getName().isEmpty()) {
                    descriptors.put(role.getName(), new RolePropertyDescriptor(role, type));
                }
            } catch (SecurityException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for role: " + role.getName());
            } catch (IntrospectionException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for role: " + role.getName());
            } catch (NoSuchMethodException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for role: " + role.getName());
            } catch (ClassNotFoundException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for role: " + role.getName());
            }
        }
    }

    for (Method method : type.getMethods()) {
        final String methodName = method.getName();
        String fieldName = StringUtils.uncapitalize(methodName.substring(3, methodName.length()));

        if (fieldName.equalsIgnoreCase("oid")) {
            continue;
        }
        if (fieldName.equals("idInternal")) {
            continue;
        }
        String replace = fieldName.replace("Count", "").replace("Set", "").replace("Iterator", "");
        if (descriptors.containsKey(replace)) {
            continue;
        }

        Method readMethod = null;
        Method writeMethod = null;

        if (!methodName.contains("$") && methodName.startsWith("get")) {
            readMethod = method;
            Class<?> returnType = readMethod.getReturnType();
            writeMethod = getSetMethod(type, fieldName, returnType);
        }

        if (readMethod != null) {
            java.beans.PropertyDescriptor propertyDescriptor;
            try {
                propertyDescriptor = new java.beans.PropertyDescriptor(fieldName, readMethod, writeMethod);
                final BeanPropertyDescriptor beanPropertyDesc = new BeanPropertyDescriptor(propertyDescriptor,
                        false);
                descriptors.put(fieldName, beanPropertyDesc);
            } catch (IntrospectionException e) {
                VaadinFrameworkLogger.getLogger()
                        .error("Failed to create property descriptor for method : " + methodName);
            }
        }
    }
}

From source file:ubic.gemma.util.BeanNameGenerator.java

/**
 * Automagically produce camel-case names for the beans.
 * //  ww  w. jav  a2 s.com
 * @see org.springframework.beans.factory.support.BeanNameGenerator#generateBeanName(org.springframework.beans.factory
 *      .config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry).
 */
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
    String name = this.gen.generateBeanName(definition, registry).replace("Impl", "").replace("#0", "")
            .replaceAll(".+\\.", "");

    name = StringUtils.uncapitalize(name);
    return name;
}