Example usage for org.apache.commons.lang3 StringUtils capitalize

List of usage examples for org.apache.commons.lang3 StringUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils capitalize.

Prototype

public static String capitalize(final String str) 

Source Link

Document

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

Usage

From source file:edu.zipcloud.cloudstreetmarket.core.util.ValidatorUtil.java

private static <T> Map<String, String> extractViolations(Set<ConstraintViolation<T>> violations) {
    Map<String, String> errors = new HashMap<String, String>();
    for (ConstraintViolation<T> v : violations) {
        errors.put(v.getPropertyPath().toString(),
                "[" + v.getPropertyPath().toString() + "] " + StringUtils.capitalize(v.getMessage()));
    }/*from w w w.  jav  a2s .co m*/
    return errors;
}

From source file:com.github.bjoern2.codegen.JavaGetterMethodImpl.java

public JavaGetterMethodImpl(JavaType type, String n) {
    setAccessType(JavaAccessType.PUBLIC);
    setStatic(false);/*from   w  w w  . ja  v a 2s  .  c  o  m*/
    setReturnType(type);
    String name = "";
    if (StringUtils.equals(type.getName(), "boolean")) {
        name += "is";
    } else {
        name += "get";
    }
    name += StringUtils.capitalize(n);

    setName(name);
    //      List<JavaField> parameters = new ArrayList<JavaField>();
    //      parameters.add(new JavaFieldImpl(new JavaTypeImpl("String", 1), "args"));
    //      m.setParameters(parameters);
    setBody("return this." + n + ";");
}

From source file:com.hortonworks.streamline.common.util.ReflectionHelper.java

public static <T> T invokeSetter(String propertyName, Object object, Object valueToSet)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    String methodName = "set" + StringUtils.capitalize(propertyName);
    Method method = object.getClass().getMethod(methodName, valueToSet.getClass());
    return (T) method.invoke(object, valueToSet);
}

From source file:com.turingtechnologies.materialscrollbar.AlphabetIndicator.java

@Override
String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
    return StringUtils
            .capitalize(((INameableAdapter) adapter).getCharacterForElement(currentSection).toString());
}

From source file:com.wesleyhome.dao.processor.method.BetweenQueryMethodGenerator.java

@Override
protected void addMethodParameters(final JMethod method, final JClass fieldType, final String parameterName) {
    method.param(JMod.FINAL, fieldType, String.format("start%s", StringUtils.capitalize(parameterName)));
    method.param(JMod.FINAL, fieldType, String.format("end%s", StringUtils.capitalize(parameterName)));
}

From source file:com.hortonworks.registries.common.util.ReflectionHelper.java

public static <T> T invokeSetter(String propertyName, Object object, Object valueToSet)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    String methodName = "set" + StringUtils.capitalize(propertyName);
    Method method = null;/*w  ww.  j  ava  2 s . co m*/
    try {
        method = object.getClass().getMethod(methodName, valueToSet.getClass());
    } catch (NoSuchMethodException ex) {
        // try setters that accept super types
        Method[] methods = object.getClass().getMethods();
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].getName().equals(methodName) && methods[i].getParameterCount() == 1) {
                if (methods[i].getParameters()[0].getType().isAssignableFrom(valueToSet.getClass())) {
                    method = methods[i];
                    break;
                }
            }
        }
        if (method == null) {
            throw ex;
        }
    }
    return (T) method.invoke(object, valueToSet);
}

From source file:com.jshnd.virp.annotation.FieldAnnotationUtil.java

FieldAnnotationUtil(Field field, Class<?> classFor) {
    this.field = field;
    this.classFor = classFor;
    String methodName = "get" + StringUtils.capitalize(field.getName());
    try {//from w  ww. j  a v a2s .c  o  m
        getter = classFor.getMethod(methodName);
    } catch (NoSuchMethodException e) {
        methodName = "is" + StringUtils.capitalize(field.getName());
        try {
            getter = classFor.getMethod(methodName);
        } catch (NoSuchMethodException e2) {
            throw new VirpAnnotationException("Getter for field " + field.getName() + " not found");
        }
    }
    try {
        setter = ReflectionUtil.getSetter(classFor, getGetMethod());
    } catch (NoSuchMethodException e) {
        throw new VirpAnnotationException("Setter for field " + field.getName() + " not found");
    }
}

From source file:com.google.testing.pogen.generator.test.java.NameConverter.java

/**
 * Converts the specified file name to a Java class name.
 * /*w w w .j av  a2s. co m*/
 * @param fileName the file name to be converted
 * @return the Java class name converted from the specified file name
 */
public static String getJavaClassName(String fileName) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(fileName));

    StringBuilder result = new StringBuilder();
    String[] strings = getJavaIdentifier(fileName).split("" + REPLACE);
    for (String string : strings) {
        result.append(StringUtils.capitalize(string));
    }
    return result.toString();
}

From source file:cn.com.infcn.ade.common.utils.Reflections.java

/**
 * Setter, ???//from   ww w.  j  a va 2s. c o m
 * ???.??.
 */
public static void invokeSetter(Object obj, String propertyName, Object value) {
    Object object = obj;
    String[] names = StringUtils.split(propertyName, ".");
    for (int i = 0; i < names.length; i++) {
        if (i < names.length - 1) {
            String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
            object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
        } else {
            String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
            invokeMethodByName(object, setterMethodName, new Object[] { value });
        }
    }
}

From source file:com.salesforce.ide.apex.internal.core.tooling.systemcompletions.model.Namespace.java

void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
    name = StringUtils.capitalize(name);

    for (Type t : type) {
        typeTrie.put(t.name.toLowerCase(), t);
    }
}