Example usage for org.springframework.util StringUtils capitalize

List of usage examples for org.springframework.util StringUtils capitalize

Introduction

In this page you can find the example usage for org.springframework.util StringUtils capitalize.

Prototype

public static String capitalize(String str) 

Source Link

Document

Capitalize a String , changing the first letter to upper case as per Character#toUpperCase(char) .

Usage

From source file:org.echocat.redprecursor.annotations.utils.AccessAlsoProtectedMembersReflectivePropertyAccessor.java

@Override
protected Method findSetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic) {
    Method result = null;/*w w w.  ja  v  a 2 s  .c o m*/
    final PropertyDescriptor propertyDescriptor = findPropertyDescriptorFor(clazz, propertyName);
    if (propertyDescriptor != null) {
        result = propertyDescriptor.getWriteMethod();
    }
    if (result == null) {
        Class<?> current = clazz;
        final String setterName = "set" + StringUtils.capitalize(propertyName);
        while (result == null && !Object.class.equals(current)) {
            final Method[] potentialMethods = current.getDeclaredMethods();
            for (Method potentialMethod : potentialMethods) {
                if (setterName.equals(potentialMethod.getName())) {
                    if (potentialMethod.getParameterTypes().length == 1) {
                        if (!mustBeStatic || Modifier.isStatic(potentialMethod.getModifiers())) {
                            if (!potentialMethod.isAccessible()) {
                                potentialMethod.setAccessible(true);
                            }
                            result = potentialMethod;
                        }
                    }
                }
            }
            current = current.getSuperclass();
        }
    }
    return result;
}

From source file:com.aw.swing.mvp.cmp.pick.PickManager.java

private static String getTxtPick(String attrName) {
    String txtPickName = "txt" + StringUtils.capitalize(attrName);
    return txtPickName;
}

From source file:com.trenako.entities.CategoriesCount.java

/**
 * Returns the field name from the {@code Category} label.
 *
 * @param cat the {@code Category} label
 * @return the field name/*w ww  .j a  v  a  2 s.co m*/
 */
public static String getKey(String cat) {
    StringBuilder sb = new StringBuilder();
    if (cat.indexOf("-") > 0) {
        String[] tokens = cat.split("-");
        sb.append(tokens[0]);
        for (int i = 1; i < tokens.length; i++) {
            sb.append(StringUtils.capitalize(tokens[i]));
        }
    } else {
        sb.append(cat);
    }

    return sb.toString();
}

From source file:com.consol.citrus.admin.converter.endpoint.AbstractEndpointConverter.java

private Method findSetter(Class<S> modelClass, String fieldName) {
    final Method[] setter = { null };

    ReflectionUtils.doWithMethods(modelClass, new ReflectionUtils.MethodCallback() {
        @Override// w  w  w . j  av a2  s.com
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
            if (method.getName().equals("set" + StringUtils.capitalize(fieldName))) {
                setter[0] = method;
            }
        }
    }, new ReflectionUtils.MethodFilter() {
        @Override
        public boolean matches(Method method) {
            return method.getName().startsWith("set");
        }
    });

    if (setter[0] == null) {
        throw new ApplicationRuntimeException(String.format(
                "Unable to find proper setter for field '%s' on model class '%s'", fieldName, modelClass));
    }

    return setter[0];
}

From source file:es.logongas.ix3.util.ReflectionUtil.java

static private <T extends Annotation> T getMethodAnnotation(Class baseClass, String methodName,
        Class<T> annotationClass) {
    String suffixMethodName = StringUtils.capitalize(methodName);
    Method method = getMethod(baseClass, "get" + suffixMethodName);
    if (method == null) {
        method = getMethod(baseClass, "is" + suffixMethodName);
        if (method == null) {
            method = getMethod(baseClass, methodName);
            if (method == null) {

                return null;
            }//  w w  w. j a va 2s  .  co  m
        }
    }
    T annotation = method.getAnnotation(annotationClass);

    return annotation;
}

From source file:com.aw.swing.mvp.cmp.pick.PickManager.java

private static String getBtnPick(String attrName) {
    String txtPickName = "btn" + StringUtils.capitalize(attrName);
    return txtPickName;
}

From source file:org.synyx.hades.dao.config.DaoContext.java

/**
 * Returns the name of the DAO interface.
 * //from  w w w.ja v a  2s .  com
 * @return
 */
public String getInterfaceName() {

    return getDaoBasePackageName() + "." + StringUtils.capitalize(id);
}

From source file:org.shept.persistence.provider.hibernate.HibernateUtils_old.java

public static Object copyTemplate(HibernateDaoSupport dao, Object entityModelTemplate) {
    if (entityModelTemplate != null) {
        // hier besser die Metadaten von Hibernate fragen
        if (null != getClassMetadata(dao, entityModelTemplate)) {
            //         if (null != AnnotationUtils.findAnnotation(entityModelTemplate.getClass(), Entity.class)) {
            String idName = HibernateUtils_old.getIdentifierPropertyName(dao, entityModelTemplate);
            Object newModel = BeanUtils.instantiateClass(entityModelTemplate.getClass());
            BeanUtils.copyProperties(entityModelTemplate, newModel, new String[] { idName });

            Serializable idx = getIdValue(dao, entityModelTemplate);

            ClassMetadata meta = getClassMetadata(dao, idx);
            Type type = meta.getIdentifierType();

            if (meta != null && type.isComponentType()) {
                // alternaitv               if (id != null && (null != AnnotationUtils.findAnnotation(id.getClass(), Embeddable.class))) {
                Serializable copyId = BeanUtils.instantiate(idx.getClass());
                BeanUtils.copyProperties(idx, copyId);
                Method idMth = ReflectionUtils.findMethod(entityModelTemplate.getClass(),
                        "set" + StringUtils.capitalize(idName), new Class[] {});
                if (idMth != null) {
                    ReflectionUtils.invokeMethod(idMth, newModel, copyId);
                }/*from  w  ww  . j a  va 2 s.co m*/
            }
            return newModel;
        }
    }
    return null;
}

From source file:net.nan21.dnet.core.presenter.converter.ReflookupResolver.java

/**
 * Get the getter for the entity-field with the given name.
 * /*  w  w w.  ja  va2  s. com*/
 * @param fieldName
 * @return
 * @throws Exception
 */
private Method _getEntityGetter(String fieldName) throws Exception {
    return this.entityClass.getMethod("get" + StringUtils.capitalize(fieldName));
}

From source file:org.synyx.hades.dao.config.DaoContext.java

/**
 * Returns the class name of a possible custom DAO implementation class to
 * detect.//from ww  w.ja  va 2s.c  o  m
 * 
 * @return
 */
public String getImplementationClassName() {

    return StringUtils.capitalize(id) + getDaoImplPostfix();
}