Java Code Examples for org.apache.commons.lang3.StringUtils#uncapitalize()
The following examples show how to use
org.apache.commons.lang3.StringUtils#uncapitalize() .
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 File: MemberContext.java From mPaaS with Apache License 2.0 | 6 votes |
/** 若member是一个字段或getter/setter,则返回字段名,否则返回null */ public String getPropertyName() { if (member instanceof Field) { return ((Field) member).getName(); } else if (member instanceof Method) { Method method = (Method) member; int count = method.getParameterCount(); String name = method.getName(); if (count == 0) { if (name.startsWith(IS)) { return StringUtils .uncapitalize(name.substring(IS.length())); } else if (name.startsWith(GETTER)) { return StringUtils .uncapitalize(name.substring(GETTER.length())); } } else if (count == 1) { if (name.startsWith(SETTER)) { return StringUtils .uncapitalize(name.substring(SETTER.length())); } } } return null; }
Example 2
Source File: HaskellHttpClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
@Override public CodegenModel fromModel(String name, Schema mod) { CodegenModel model = super.fromModel(name, mod); // while (typeNames.contains(model.classname)) { // model.classname = generateNextName(model.classname); // } typeNames.add(model.classname); modelTypeNames.add(model.classname); // From the model name, compute the prefix for the fields. String prefix = StringUtils.uncapitalize(model.classname); for (CodegenProperty prop : model.vars) { prop.name = toVarName(prefix, prop.name); } return model; }
Example 3
Source File: JavaTemplateFunction.java From youran with Apache License 2.0 | 6 votes |
/** * 打印gettersetter方法 * * @param jfieldName java字段名 * @param jfieldType java字段类型 * @param override 是否加上@Override注解 * @param indent 缩进层次 * @return */ public static String printGetterSetter(String jfieldName, String jfieldType, boolean override, int indent) { StringBuilder indentPrefix = new StringBuilder(); for (int i = 0; i < indent; i++) { indentPrefix.append(" "); } String cap = StringUtils.capitalize(jfieldName); String uncap = StringUtils.uncapitalize(jfieldName); StringBuilder sb = new StringBuilder(); if (override) { sb.append(indentPrefix).append("@Override\n"); } sb.append(indentPrefix).append("public ").append(jfieldType).append(" get").append(cap).append("() {\n") .append(indentPrefix).append(" return this.").append(uncap).append(";\n") .append(indentPrefix).append("}\n") .append("\n"); if (override) { sb.append(indentPrefix).append("@Override\n"); } sb.append(indentPrefix).append("public void set").append(cap).append("(").append(jfieldType).append(" ").append(uncap).append(") {\n") .append(indentPrefix).append(" this.").append(uncap).append(" = ").append(uncap).append(";\n") .append(indentPrefix).append("}\n\n"); return sb.toString(); }
Example 4
Source File: MemberContext.java From mPass with Apache License 2.0 | 6 votes |
/** 若member是一个字段或getter/setter,则返回字段名,否则返回null */ public String getPropertyName() { if (member instanceof Field) { return ((Field) member).getName(); } else if (member instanceof Method) { Method method = (Method) member; int count = method.getParameterCount(); String name = method.getName(); if (count == 0) { if (name.startsWith(IS)) { return StringUtils .uncapitalize(name.substring(IS.length())); } else if (name.startsWith(GETTER)) { return StringUtils .uncapitalize(name.substring(GETTER.length())); } } else if (count == 1) { if (name.startsWith(SETTER)) { return StringUtils .uncapitalize(name.substring(SETTER.length())); } } } return null; }
Example 5
Source File: LookupKeyStrategy.java From onetwo with Apache License 2.0 | 5 votes |
default String getName() { String name = this.getClass().getSimpleName(); String postfix = LookupKeyStrategy.class.getSimpleName(); if(name.endsWith(postfix)){ name = name.substring(0, name.length()-postfix.length()); name = StringUtils.uncapitalize(name); } return name; }
Example 6
Source File: LoggingInvocationHandler.java From masquerade with Apache License 2.0 | 5 votes |
private void logExecution(Method method, Object[] args) { if (args != null && args.length >= 1) { if (method.getName().startsWith("set") && args.length == 1) { String propertyName = StringUtils.uncapitalize(method.getName().substring("set".length())); log.info("Set '{}' of '{}' to '{}'", propertyName, targetId, args[0]); } else { log.info("{} of '{}' with {}", formatMethodName(method), targetId, args); } } else { log.info("{} '{}'", formatMethodName(method), targetId); } }
Example 7
Source File: UncapitalizeTransformator.java From SkaETL with Apache License 2.0 | 5 votes |
@Override public void apply(String idProcess, ParameterTransformation parameterTransformation, ObjectNode jsonValue) { if (has(parameterTransformation.getKeyField(),jsonValue)) { JsonNode valueField = at(parameterTransformation.getKeyField(), jsonValue); String capitalized = StringUtils.uncapitalize(valueField.textValue()); put(jsonValue, parameterTransformation.getKeyField(), capitalized); } }
Example 8
Source File: WebExceptionHandlerOperationsImpl.java From gvnix with GNU General Public License v3.0 | 5 votes |
/** * Returns the exception view name checking if exists in the file * webmvc-config.xml file. * * @param exceptionName to create the view. * @param root {@link Element} with the values off webmvc-config.xml * @return */ private String getExceptionViewName(String exceptionName) { // View name for this Exception. int index = exceptionName.lastIndexOf('.'); String exceptionViewName = exceptionName; if (index >= 0) { exceptionViewName = exceptionName.substring(index + 1); } exceptionViewName = StringUtils.uncapitalize(exceptionViewName); boolean exceptionNameExists = true; int exceptionCounter = 2; String tmpExceptionViewName = exceptionViewName; while (exceptionNameExists) { exceptionNameExists = fileManager.exists(pathResolver .getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), "WEB-INF/views/" + tmpExceptionViewName + JSPX_EXTENSION)); if (exceptionNameExists) { tmpExceptionViewName = exceptionViewName.concat(Integer .toString(exceptionCounter++)); } } return tmpExceptionViewName; }
Example 9
Source File: AbstractResourceProvider.java From android-codegenerator-library with Apache License 2.0 | 5 votes |
private String getResourceName(Resource resource) { String idName = resource.getResourceId().getName(); StringBuilder stringBuilder = new StringBuilder(); for (String word : idName.split("_")) { stringBuilder.append(StringUtils.capitalize(word)); } return StringUtils.uncapitalize(stringBuilder.toString()); }
Example 10
Source File: NameUtils.java From livingdoc-core with GNU General Public License v3.0 | 5 votes |
public static String toLowerCamelCase(String s) { if (StringUtils.isBlank(s)) { return s.trim(); } return StringUtils.uncapitalize(StringUtils.deleteWhitespace(WordUtils.capitalizeFully(s))); }
Example 11
Source File: MethodCodeGenerator.java From sqlbrite-dao with Apache License 2.0 | 5 votes |
@Override public void generateContentValuesBuilderMethod(TypeSpec.Builder builder, TypeName type, String contentValuesVarName) { String methodName = method.getMethodName(); methodName = HungarianNotation.removeNotationFromSetterAndSetPrefix(methodName); methodName = StringUtils.uncapitalize(methodName); // setter method builder.addMethod(MethodSpec.methodBuilder(methodName) .addJavadoc("Adds the given value to this ContentValues\n") .addJavadoc("@param value The value\n") .addJavadoc("@return $T\n", type) .addModifiers(Modifier.PUBLIC) .addParameter(TypeName.get(method.getParameter().asType()), "value", Modifier.FINAL) .returns(type) .addStatement("$L.put($S, value)", contentValuesVarName, method.getColumnName()) .addStatement("return this") .build()); // null method builder.addMethod(MethodSpec.methodBuilder(methodName + "AsNull") .addModifiers(Modifier.PUBLIC) .addJavadoc("Adds a null value to this ContentValues\n") .addJavadoc("@return $T\n", type) .returns(type) .addStatement("$L.putNull( $S )", contentValuesVarName, method.getColumnName()) .addStatement("return this") .build()); }
Example 12
Source File: UnitBasicQueryService.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
/** * Page query by parameter name and parameter value. * * @param UnitParaQueryPageReq * @param unitType * @return */ public CommonResponse getPageListByReq(UnitParaQueryPageReq<String> req, String unitType) { String repositoryName = StringUtils.uncapitalize(req.getUnitName() + unitType); if (repositoryService.getJpaSpecificationExecutor(repositoryName).isPresent()) { JpaSpecificationExecutor j = repositoryService.getJpaSpecificationExecutor(repositoryName).get(); return commonQueryService.getPageListByCommonReq(req, j); } else { return ResponseUtils.paramError("The unit name is invalid: " + req.getUnitName()); } }
Example 13
Source File: MetaEntityScanListener.java From mPaaS with Apache License 2.0 | 5 votes |
/** 自动填充Entity信息 */ private void fillEntityDefault(MetaEntityImpl entity) { String simpleName = entity.getEntityName(); int index = simpleName.lastIndexOf(DOT); if (index == -1) { return; } entity.setModule(LocalMetaContextHolder.get() .matchModule(entity.getEntityName())); // KmReviewMain -> kmReviewMain simpleName = StringUtils.uncapitalize(simpleName.substring(index + 1)); // messageKey/label if (entity.getMessageKey() == null) { if (entity.getModule() != null) { String messageKey = StringHelper.join(entity.getModule(), ":table.", simpleName); String label = ResourceUtil.getString(messageKey); if (label != null) { entity.setMessageKey(messageKey); entity.setLabel(label); } } } else { entity.setLabel(ResourceUtil.getString(entity.getMessageKey())); } // displayProperty if (entity.getDisplayProperty() == null) { for (String displayProperty : DISPLAY_PROPERTY) { if (entity.getProperty(displayProperty) != null) { entity.setDisplayProperty(displayProperty); break; } } } // feature tranFeatures(entity.getFeatures()); // properties fillPropertyDefault(entity, simpleName); }
Example 14
Source File: BatchUpdateControllerGenerator.java From maven-archetype with GNU Lesser General Public License v2.1 | 5 votes |
public static List<Method> generator(FullyQualifiedJavaType innerClassType,String beanName, String businessFieldName){ List<Method> methodList = new ArrayList<Method>(); String innerClassFiledName = StringUtils.uncapitalize(innerClassType.getShortName()); Method method = new Method(); method.addAnnotation("@RequestMapping(value = \"batchUpdateSave" + beanName + ".do\")"); method.setVisibility(JavaVisibility.PUBLIC); method.setReturnType(new FullyQualifiedJavaType(String.class.getName())); method.setName("batchUpdateSave" + beanName); Parameter param1 = new Parameter(innerClassType, innerClassFiledName); param1.addAnnotation("@ModelAttribute "); Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map"); method.addParameter(param1); method.addParameter(paramModelMap); // 方法body method.addBodyLine("try {"); method.addBodyLine("if(" + innerClassFiledName + " != null && CollectionUtil.isNotNull(" + innerClassFiledName + ".get"+ beanName + "List())){"); method.addBodyLine("int updateCount = this." + businessFieldName + ".update(" + innerClassFiledName + ".get"+ beanName + "List());"); method.addBodyLine("if(updateCount >0 ){"); method.addBodyLine("map.put(\"message\",\"更新成功。\");"); method.addBodyLine("}else{"); method.addBodyLine("map.put(\"message\",\"更新失败。\");"); method.addBodyLine("}"); method.addBodyLine("}"); method.addBodyLine("} catch (Exception e) {"); method.addBodyLine("logger.error(\"批量更新异常\" + e.getMessage());"); method.addBodyLine("map.put(\"message\", \"批量更新异常\" + e.getMessage());"); method.addBodyLine("}"); method.addBodyLine(ControllerPluginUtil.RETURN); methodList.add(method); return methodList; }
Example 15
Source File: JpaBatchMetadata.java From gvnix with GNU General Public License v3.0 | 4 votes |
/** * Return method to create a list of entities * * @return */ private MethodMetadata getCreateMethod() { // Define parameters types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType .convertFromJavaTypes(listOfEntitiesType); // Check if a method exist in type final MethodMetadata method = methodExists(CREATE_METHOD, parameterTypes); if (method != null) { // If it already exists, just return the method return method; } // Define method annotations (none in this case) List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(new AnnotationMetadataBuilder( SpringJavaType.TRANSACTIONAL)); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names (none in this case) JavaSymbolName parameterName = new JavaSymbolName( StringUtils.uncapitalize(entityPlural)); List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(parameterName); // --- Create the method body --- InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); // for(Vet vet : vets) { // vet.persist(); // } bodyBuilder.appendFormalLine(String.format("for( %s %s : %s) {", entityName, entityName.toLowerCase(), parameterName)); bodyBuilder.indent(); bodyBuilder.appendFormalLine(String.format("%s.persist();", entityName.toLowerCase())); bodyBuilder.indentRemove(); bodyBuilder.appendFormalLine("}"); // Use the MethodMetadataBuilder for easy creation of MethodMetadata JavaType returnType = JavaType.VOID_PRIMITIVE; MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder( getId(), Modifier.PUBLIC, CREATE_METHOD, returnType, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
Example 16
Source File: WebJpaBatchMetadata.java From gvnix with GNU General Public License v3.0 | 4 votes |
public WebJpaBatchMetadata(String identifier, JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, WebJpaBatchAnnotationValues annotationValues, JpaBatchMetadata jpaBatchMetadata, WebScaffoldAnnotationValues webScaffoldMetadataValue) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '" + identifier + "' does not appear to be a valid"); this.helper = new WebItdBuilderHelper(this, governorPhysicalTypeMetadata, builder.getImportRegistrationResolver()); this.annotationValues = annotationValues; this.service = annotationValues.getService(); Validate.notNull(service, String.format( "Missing service value required for %s in %s", WebJpaBatchAnnotationValues.WEB_JPA_BATCH_ANNOTATION .getFullyQualifiedTypeName(), governorPhysicalTypeMetadata.getType() .getFullyQualifiedTypeName())); this.jpaBatchMetadata = jpaBatchMetadata; listOfIdentifiersType = jpaBatchMetadata.getListOfIdentifiersType(); listOfEntityType = jpaBatchMetadata.getListOfEntitiesType(); this.entity = jpaBatchMetadata.getEntity(); this.entityName = JavaSymbolName.getReservedWordSafeName(entity) .getSymbolName(); this.entityIdentifier = jpaBatchMetadata.getEntityIdentifier(); listOfEntityName = new JavaSymbolName( StringUtils.uncapitalize(jpaBatchMetadata.getEntityPlural())); jsonResponseList = new JavaType( JSON_RESPONSE.getFullyQualifiedTypeName(), 0, DataType.TYPE, null, Arrays.asList(listOfEntityType)); Validate.notNull(this.entity, String.format( "Missing entity value for %s in %s", GvNIXJpaBatch.class.getCanonicalName(), service.getFullyQualifiedTypeName())); Validate.isTrue( this.entity.equals(webScaffoldMetadataValue .getFormBackingObject()), String.format( "Service batch entity and Controller formBackingObject no match in %s", governorPhysicalTypeMetadata.getType() .getFullyQualifiedTypeName())); // Adding field definition builder.addField(getConversionServiceField()); builder.addField(getLoggerField()); // Adding methods builder.addField(getServiceField()); builder.addMethod(getDeleteMethod()); builder.addMethod(getUpdateMethod()); builder.addMethod(getCreateMethod()); builder.addMethod(getGetOIDListMethod()); builder.addMethod(getGetRequestPropertyValuesMethod()); // Check if deleteBatch, createBatch or updateBatch are duplicated with // different name. checkIfExistsCUDMethods(governorTypeDetails); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
Example 17
Source File: CamundaBpmAutoConfigurationIT.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
private String convertToBeanName(Class<?> beanClass) { return StringUtils.uncapitalize(beanClass.getSimpleName()); }
Example 18
Source File: Uncapitalize.java From vscrawler with Apache License 2.0 | 4 votes |
@Override protected String handleSingleStr(String input) { return StringUtils.uncapitalize(input); }
Example 19
Source File: FastSerializerGeneratorBase.java From avro-fastserde with Apache License 2.0 | 4 votes |
protected static String getVariableName(String name) { return StringUtils.uncapitalize(name) + nextRandomInt(); }
Example 20
Source File: AnalysisDB.java From fast-family-master with Apache License 2.0 | 4 votes |
private static final void fillTableColInfo(TableInfo table, GeneratorConfig dbConfig) { List<ColumnInfo> list = new ArrayList<>(); String sql = "SELECT DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,COLUMN_NAME,ORDINAL_POSITION,IS_NULLABLE,COLUMN_DEFAULT,COLUMN_TYPE,COLUMN_KEY,EXTRA,COLUMN_COMMENT" + " FROM information_schema.columns WHERE table_schema = '" + dbConfig.getDbName() + "' AND table_name = '" + table.getTableName() + "'"; PreparedStatement ps = null; ResultSet rs = null; try { ps = DBHandler.createConnection(dbConfig).prepareStatement(sql); rs = ps.executeQuery(); while (rs.next()) { ColumnInfo fm = new ColumnInfo(); String columnName = rs.getString("COLUMN_NAME"); String columnJavaName = StringUtils.uncapitalize(WordUtils.columnToJava(columnName)); if (!"createTime".equals(columnJavaName) && !"lastUpTime".equals(columnJavaName)) { String dataType = rs.getString("DATA_TYPE"); String columnType = rs.getString("COLUMN_TYPE"); String length = rs.getString("CHARACTER_MAXIMUM_LENGTH"); if (StringUtils.isBlank(length)) { if (columnType.indexOf("(") != -1) { length = columnType.substring(columnType.indexOf("(") + 1, columnType.indexOf(")")); } } fm.setLength(length); fm.setDataType(dataType); fm.setColumnComment(rs.getString("COLUMN_COMMENT")); fm.setColumnDefault(rs.getString("COLUMN_DEFAULT")); fm.setColumnKey(rs.getString("COLUMN_KEY")); fm.setColumnName(columnName); fm.setColumnJavaName(columnJavaName); fm.setColumnType(rs.getString("COLUMN_TYPE")); fm.setExtra(rs.getString("EXTRA")); fm.setIsNullable(rs.getString("IS_NULLABLE")); fm.setOrdinalPosition(rs.getString("COLUMN_COMMENT")); list.add(fm); } } table.setColumnInfoList(list); } catch (SQLException e) { e.printStackTrace(); } }