Java Code Examples for org.springframework.util.StringUtils#capitalize()

The following examples show how to use org.springframework.util.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
/**
 * Generate a suitable application name based on the specified name. If no suitable
 * application name can be generated from the specified {@code name}, the
 * {@link Env#getFallbackApplicationName()} is used instead.
 * <p>
 * No suitable application name can be generated if the name is {@code null} or if it
 * contains an invalid character for a class identifier.
 * @param name the the source name
 * @return the generated application name
 * @see Env#getFallbackApplicationName()
 * @see Env#getInvalidApplicationNames()
 */
public String generateApplicationName(String name) {
	if (!StringUtils.hasText(name)) {
		return this.env.fallbackApplicationName;
	}
	String text = splitCamelCase(name.trim());
	// TODO: fix this
	String result = unsplitWords(text);
	if (!result.endsWith("Application")) {
		result = result + "Application";
	}
	String candidate = StringUtils.capitalize(result);
	if (hasInvalidChar(candidate) || this.env.invalidApplicationNames.contains(candidate)) {
		return this.env.fallbackApplicationName;
	}
	else {
		return candidate;
	}
}
 
Example 2
/**
 * Return the method suffix for a given property name. The default implementation
 * uses JavaBean conventions.
 */
protected String getPropertyMethodSuffix(String propertyName) {
	if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
		return propertyName;
	}
	return StringUtils.capitalize(propertyName);
}
 
Example 3
@Override
protected String getBeanClassName(Element element) {
    String elementName
            = Conventions.attributeNameToPropertyName(
                    element.getLocalName());
    return RedissonNamespaceParserSupport.IMPL_CLASS_PATH_PREFIX
            + StringUtils.capitalize(elementName);
}
 
Example 4
@Override
public String getGeneratedFilePath(MethodMetaInfo method) {
    String packagePath = PackagePath.getPackagePath(PackageConstants.CRAWLER_METHOD_IMPL_PACKAGE_POSTFIX,
            systemEnvironmentConfig.getGroup(), PackageConstants.SUB_PROJECT_PKG_PARSER);
    String className = method.getContractName() + StringUtils.capitalize(method.getName());
    String javaFilePath = packagePath + "/" + className + "MethodCrawlerImpl.java";
    return javaFilePath;
}
 
Example 5
/**
 * Return the method suffix for a given property name. The default implementation
 * uses JavaBean conventions.
 */
protected String getPropertyMethodSuffix(String propertyName) {
	if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
		return propertyName;
	}
	return StringUtils.capitalize(propertyName);
}
 
Example 6
@Override
public String getGeneratedFilePath(MethodMetaInfo method) {
    String packagePath = PackagePath.getPackagePath(PackageConstants.DB__METHOD_REPOSITORY_PACKAGE_POSTFIX,
            systemEnvironmentConfig.getGroup(), PackageConstants.SUB_PROJECT_PKG_DB);
    String className = method.getContractName() + StringUtils.capitalize(method.getName());
    String javaFilePath = packagePath + "/" + className + "MethodRepository.java";
    return javaFilePath;
}
 
Example 7
private String getClassName(TypeDeclaration type) {
	UnionTypeDeclaration objectType = (UnionTypeDeclaration) type;
	String name = StringUtils.capitalize(objectType.name());

	// For mime types we need to take the type not the name
	try {
		MimeType.valueOf(name);
		name = objectType.type();
	} catch (Exception ex) {
		// not a valid mimetype do nothing
		logger.debug("mime: " + name);
	}
	return name;
}
 
Example 8
/**
 * Springfox configuration for the management endpoints (actuator) Swagger docs.
 *
 * @param appName               the application name
 * @param managementContextPath the path to access management endpoints
 * @return the Swagger Springfox configuration
 */
@Bean
@ConditionalOnClass(name = "org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties")
@ConditionalOnProperty("management.endpoints.web.base-path")
@ConditionalOnExpression("'${management.endpoints.web.base-path}'.length() > 0")
@ConditionalOnMissingBean(name = "swaggerSpringfoxManagementDocket")
public Docket swaggerSpringfoxManagementDocket(@Value("${spring.application.name:application}") String appName,
                                               @Value("${management.endpoints.web.base-path}") String managementContextPath) {

    ApiInfo apiInfo = new ApiInfo(
        StringUtils.capitalize(appName) + " " + MANAGEMENT_TITLE_SUFFIX,
        MANAGEMENT_DESCRIPTION,
        properties.getVersion(),
        "",
        ApiInfo.DEFAULT_CONTACT,
        "",
        "",
        new ArrayList<>()
    );

    return createDocket()
        .apiInfo(apiInfo)
        .useDefaultResponseMessages(properties.isUseDefaultResponseMessages())
        .groupName(MANAGEMENT_GROUP_NAME)
        .host(properties.getHost())
        .protocols(new HashSet<>(Arrays.asList(properties.getProtocols())))
        .forCodeGeneration(true)
        .directModelSubstitute(ByteBuffer.class, String.class)
        .genericModelSubstitutes(ResponseEntity.class)
        .ignoredParameterTypes(Pageable.class)
        .select()
        .paths(regex(managementContextPath + ".*"))
        .build();
}
 
Example 9
private static String generateMessage(String entity, String field, String val) {
    return StringUtils.capitalize(entity)
            + " with " + field + " "+ val + " does not exist";
}
 
Example 10
private static String getActionNameFromObjects(ApiActionMetadata apiActionMetadata) {

		String uri = apiActionMetadata.getResource().getUri();
		String name = convertActionTypeToIntent(apiActionMetadata.getActionType(), doesUriEndsWithParam(uri));

		if (apiActionMetadata.getActionType().equals(RamlActionType.GET)) {
			Map<String, ApiBodyMetadata> responseBody = apiActionMetadata.getResponseBody();
			if (responseBody.size() > 0) {
				ApiBodyMetadata apiBodyMetadata = responseBody.values().iterator().next();
				String responseObjectName = cleanNameForJava(StringUtils.capitalize(apiBodyMetadata.getName()));
				if (apiBodyMetadata.isArray()) {
					responseObjectName = StringUtils.capitalize(NamingHelper.pluralize(responseObjectName));
				}
				name += responseObjectName;
			} else {
				name += "Object";
			}

			name = appendActionNameWithSingleParameter(apiActionMetadata, name);

		} else if (apiActionMetadata.getActionType().equals(RamlActionType.DELETE)) {

			// for DELETE method we'll still use resource name
			String url = cleanLeadingAndTrailingNewLineAndChars(apiActionMetadata.getResource().getUri());
			String[] splitUrl = SLASH.split(url);
			String resourceNameToUse = null;
			if (splitUrl.length > 1 && StringUtils.countOccurrencesOf(splitUrl[splitUrl.length - 1], "{") > 0) {
				resourceNameToUse = splitUrl[splitUrl.length - 2];
			} else {
				resourceNameToUse = splitUrl[splitUrl.length - 1];
			}

			name = name + StringUtils.capitalize(cleanNameForJava(singularize(resourceNameToUse)));
			name = appendActionNameWithSingleParameter(apiActionMetadata, name);

		} else {
			ApiBodyMetadata requestBody = apiActionMetadata.getRequestBody();
			String creationObject;
			if (requestBody != null) {
				creationObject = requestBody.getName();
			} else {
				creationObject = apiActionMetadata.getParent().getResourceUri();
				creationObject = creationObject.substring(creationObject.lastIndexOf('/') + 1);
			}
			return name + cleanNameForJava(StringUtils.capitalize(creationObject));
		}

		return name;
	}
 
Example 11
private static String generateMessage(String entity, Map<String, String> searchParams) {
    return StringUtils.capitalize(entity) +
            " was not found for parameters " +
            searchParams;
}
 
Example 12
private Method getMethodForHttpStatus(HttpStatus status) throws NoSuchMethodException {
	String name = status.name().toLowerCase().replace("_", "-");
	name = "is" + StringUtils.capitalize(Conventions.attributeNameToPropertyName(name));
	return StatusResultMatchers.class.getMethod(name);
}
 
Example 13
private static String generateMessage(String entity, String field, String val) {
	return StringUtils.capitalize(entity)
		+ " with " + field + " " + val + " existed";
}
 
Example 14
private Method getMethodForHttpStatus(HttpStatus status) throws NoSuchMethodException {
	String name = status.name().toLowerCase().replace("_", "-");
	name = "is" + StringUtils.capitalize(Conventions.attributeNameToPropertyName(name));
	return StatusResultMatchers.class.getMethod(name);
}
 
Example 15
Source Project: eladmin   File: EntityExistException.java    License: Apache License 2.0 4 votes vote down vote up
private static String generateMessage(String entity, String field, String val) {
    return StringUtils.capitalize(entity)
            + " with " + field + " "+ val + " existed";
}
 
Example 16
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
	return "wicketextension"+StringUtils.capitalize(super.generateBeanName(definition, registry));
}
 
Example 17
private Method getMethodForHttpStatus(HttpStatus status) throws NoSuchMethodException {
	String name = status.name().toLowerCase().replace("_", "-");
	name = "is" + StringUtils.capitalize(Conventions.attributeNameToPropertyName(name));
	return StatusResultMatchers.class.getMethod(name);
}
 
Example 18
Source Project: lams   File: JmxUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Return the JMX attribute name to use for the given JavaBeans property.
 * <p>When using strict casing, a JavaBean property with a getter method
 * such as {@code getFoo()} translates to an attribute called
 * {@code Foo}. With strict casing disabled, {@code getFoo()}
 * would translate to just {@code foo}.
 * @param property the JavaBeans property descriptor
 * @param useStrictCasing whether to use strict casing
 * @return the JMX attribute name to use
 */
public static String getAttributeName(PropertyDescriptor property, boolean useStrictCasing) {
	if (useStrictCasing) {
		return StringUtils.capitalize(property.getName());
	}
	else {
		return property.getName();
	}
}
 
Example 19
/**
 * Convert a name into a java className.
 *
 * eg. MonitorServiceImpl becomes Monitor
 *
 * @param clazz
 *            The name
 * @return The name for this using Java class convention
 */
public static String convertToClassName(String clazz) {
	return StringUtils.capitalize(cleanNameForJava(clazz, false));
}
 
Example 20
/**
 * 首字母大写
 *
 * @param input
 *            输入文本
 * @return 首字母大写
 */
public String capitalize(String input) {
	return StringUtils.capitalize(input);
}