Java Code Examples for org.apache.commons.lang3.StringUtils#capitalize()
The following examples show how to use
org.apache.commons.lang3.StringUtils#capitalize() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openapi-generator File: HaskellHttpClientCodegen.java License: Apache License 2.0 | 6 votes |
@Override public String toEnumVarName(String value, String datatype) { if (!genEnums) return super.toEnumVarName(value, datatype); List<String> num = new ArrayList<>(Arrays.asList("integer", "int", "double", "long", "float")); if (value.length() == 0) { return "'Empty"; } // for symbol, e.g. $, # if (getSymbolName(value) != null) { return "'" + StringUtils.capitalize(sanitizeName(getSymbolName(value))); } // number if (num.contains(datatype.toLowerCase(Locale.ROOT))) { String varName = "Num" + value; varName = varName.replaceAll("-", "Minus_"); varName = varName.replaceAll("\\+", "Plus_"); varName = varName.replaceAll("\\.", "_Dot_"); return "'" + StringUtils.capitalize(sanitizeName(varName)); } return "'" + StringUtils.capitalize(sanitizeName(value)); }
Example 2
Source Project: streamline File: ReflectionHelper.java License: Apache License 2.0 | 6 votes |
public static <T> T invokeSetter(String propertyName, Object object, Object valueToSet) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { String methodName = "set" + StringUtils.capitalize(propertyName); Method method = null; 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); }
Example 3
Source Project: vk-java-sdk File: NotifyIssueChangesJob.java License: MIT License | 6 votes |
private String changedIssueMessage(Issue issue, IssueChange change) { String changes = ""; if (change != null) { changes = "Changes:\n"; for (IssueChangeField field : change.getFields()) { if (SKIP_FIELDS.contains(field.getName()) || StringUtils.isEmpty(field.getName())) { continue; } if (field.getName().equals("updaterName")) { changes += "Updater: " + field.getValue() + "\n"; } else { changes += StringUtils.capitalize(field.getName()) + ": " + field.getOldValue() + " > " + field.getNewValue() + "\n"; } } changes += "\n\n"; } String url = Application.ytHost() + "/issue/" + issue.getId(); String summary = issue.getFieldValue("summary") != null ? issue.getFieldValue("summary") : ""; String description = issue.getFieldValue("description") != null ? issue.getFieldValue("description") : ""; String title = summary.isEmpty() ? description.substring(0, Math.min(description.length(), 100)) + "..." : summary; return issue.getId() + "\n" + "Issue updated" + "\n" + issue.getFieldValue("Type") + " - " + title + "\n\n" + changes + url + "\n-------"; }
Example 4
Source Project: DDMQ File: BeanUtils.java License: Apache License 2.0 | 6 votes |
public static <T> T populate(final KeyValue properties, final T obj) { Class<?> clazz = obj.getClass(); try { final Set<String> keySet = properties.keySet(); for (String key : keySet) { String[] keyGroup = key.split("\\."); for (int i = 0; i < keyGroup.length; i++) { keyGroup[i] = keyGroup[i].toLowerCase(); keyGroup[i] = StringUtils.capitalize(keyGroup[i]); } String beanFieldNameWithCapitalization = StringUtils.join(keyGroup); try { setProperties(clazz, obj, "set" + beanFieldNameWithCapitalization, properties.getString(key)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { //ignored... } } } catch (RuntimeException e) { log.warn("Error occurs !", e); } return obj; }
Example 5
Source Project: o2oa File: WrapCopierFactory.java License: GNU Affero General Public License v3.0 | 5 votes |
private static String getGetterName(Field field) throws Exception { if (field.getType() == boolean.class) { return IS_PREFIX + StringUtils.capitalize(field.getName()); } else { return GET_PREFIX + StringUtils.capitalize(field.getName()); } }
Example 6
Source Project: requirementsascode File: FlowCondition.java License: Apache License 2.0 | 5 votes |
private String getFlowPredicate(Flow flow) { String predicate = getFlowPosition(flow) + getFlowPredicateSeparator(flow, PREDICATE_SEPARATOR) + getCondition(flow); String sep = "".equals(predicate) ? "" : PREDICATE_POSTFIX; String capitalizedPredicateWithColon = StringUtils.capitalize(predicate) + sep; return capitalizedPredicateWithColon; }
Example 7
Source Project: cuba File: WebAbstractDataGrid.java License: Apache License 2.0 | 5 votes |
protected void addColumnInternal(ColumnImpl<E> column, int index) { Grid.Column<E, ?> gridColumn = component.addColumn( new EntityValueProvider<>(column.getPropertyPath())); columns.put(column.getId(), column); columnsOrder.add(index, column); final String caption = StringUtils.capitalize(column.getCaption() != null ? column.getCaption() : generateColumnCaption(column)); column.setCaption(caption); if (column.getOwner() == null) { column.setOwner(this); } MetaPropertyPath propertyPath = column.getPropertyPath(); if (propertyPath != null) { MetaProperty metaProperty = propertyPath.getMetaProperty(); MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath); String storeName = metadataTools.getStoreName(propertyMetaClass); if (metadataTools.isLob(metaProperty) && !persistenceManagerClient.supportsLobSortingAndFiltering(storeName)) { column.setSortable(false); } } setupGridColumnProperties(gridColumn, column); component.setColumnOrder(getColumnOrder()); }
Example 8
Source Project: RuoYi-Vue File: ReflectUtils.java License: MIT License | 5 votes |
/** * 调用Getter方法. * 支持多级,如:对象名.对象名.方法 */ @SuppressWarnings("unchecked") public static <E> E invokeGetter(Object obj, String propertyName) { Object object = obj; for (String name : StringUtils.split(propertyName, ".")) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } return (E) object; }
Example 9
Source Project: sunbird-lms-service File: TelemetryGenerator.java License: MIT License | 5 votes |
private static Target generateTargetObject(Map<String, Object> targetObject) { Target target = new Target( (String) targetObject.get(JsonKey.ID), StringUtils.capitalize((String) targetObject.get(JsonKey.TYPE))); if (targetObject.get(JsonKey.ROLLUP) != null) { target.setRollup((Map<String, String>) targetObject.get(JsonKey.ROLLUP)); } return target; }
Example 10
Source Project: ace-cache File: ReflectionUtils.java License: Apache License 2.0 | 5 votes |
/** * 调用Getter方法. * 支持多级,如:对象名.对象名.方法 */ public static Object invokeGetter(Object obj, String propertyName) { Object object = obj; for (String name : StringUtils.split(propertyName, ".")) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{}); } return object; }
Example 11
Source Project: gocd File: AbstractTask.java License: Apache License 2.0 | 5 votes |
public String getConditionsForDisplay() { if (runIfConfigs.isEmpty()) { return StringUtils.capitalize(RunIfConfig.PASSED.toString()); } List<String> capitalized = runIfConfigs.stream().map(f -> StringUtils.capitalize(f.toString())).collect(Collectors.toList()); return StringUtils.join(capitalized, ", "); }
Example 12
Source Project: bisq-core File: Res.java License: GNU Affero General Public License v3.0 | 4 votes |
public static String getWithCap(String key) { return StringUtils.capitalize(get(key)); }
Example 13
Source Project: arcusandroid File: MotorizedDoorProxyModel.java License: Apache License 2.0 | 4 votes |
public String label() { return StringUtils.capitalize(StringUtils.lowerCase(name())); }
Example 14
Source Project: cloudbreak File: AuditEventToGrpcAuditEventConverter.java License: Apache License 2.0 | 4 votes |
private String formatAuditEventName(AuditEvent source) { String camelCaseFormat = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, source.getEventName().name()); return StringUtils.capitalize(camelCaseFormat); }
Example 15
Source Project: spring-boot-quickstart File: Reflections.java License: Apache License 2.0 | 4 votes |
/** * 调用Getter方法. */ public static Object invokeGetter(Object obj, String propertyName) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(propertyName); return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); }
Example 16
Source Project: caffeine File: SampledPolicy.java License: Apache License 2.0 | 4 votes |
public String label() { return StringUtils.capitalize(name().toLowerCase(US)); }
Example 17
Source Project: startup-os File: Strings.java License: Apache License 2.0 | 4 votes |
public static String capitalize(String string) { return StringUtils.capitalize(string); }
Example 18
Source Project: crnk-framework File: AbstractResponseGenerator.java License: Apache License 2.0 | 4 votes |
AbstractResponseGenerator(MetaResource metaResource) { this.metaResource = metaResource; prefix = StringUtils.capitalize(metaResource.getResourceType()); }
Example 19
Source Project: MtgDesktopCompanion File: MagicFormat.java License: GNU General Public License v3.0 | 2 votes |
public void setFormat(FORMATS standard) { format = StringUtils.capitalize(standard.name().toLowerCase()); }
Example 20
Source Project: conjure File: FieldNameValidator.java License: Apache License 2.0 | 2 votes |
/** * Converts this {@link FieldName} to an upper camel case string (e.g. myVariant -> MyVariant). * Note that the resultant string is no longer a valid {@link FieldName}. */ public static String capitalize(FieldName fieldName) { return StringUtils.capitalize(fieldName.get()); }