List of usage examples for org.springframework.util StringUtils uncapitalize
public static String uncapitalize(String str)
From source file:org.web4thejob.context.ContextUtil.java
@SuppressWarnings("unchecked") public static <T extends Dialog> T getDialog(Class<T> type, Object... args) { return (T) ContextUtil.getBean(StringUtils.uncapitalize(type.getSimpleName()), args); }
From source file:org.agatom.springatom.cmp.action.model.AbstractAction.java
/** {@inheritDoc} */ @Override public String getMode() { return StringUtils.uncapitalize(ClassUtils.getShortName(this.getClass())); }
From source file:org.web4thejob.context.ContextUtil.java
@SuppressWarnings("unchecked") public static <T extends Dialog> T getDefaultDialog(Class<T> type, Object... args) { return (T) ContextUtil.getBean(StringUtils.uncapitalize(DEFAULT_PREFFIX + type.getSimpleName()), args); }
From source file:com.springinpractice.ch11.web.sitemap.Sitemap.java
private void buildCrudNodes(Class<?> entityClass, SitemapNode dashboard) { String simpleName = entityClass.getSimpleName(); String uncapSimpleName = StringUtils.uncapitalize(simpleName); // List node//from w w w . ja v a 2 s. c o m String listTitleCode = "entity." + uncapSimpleName + ".sentenceCase.plural"; log.debug("Looking up message code: {}", listTitleCode); String listTitle = wrap(messageSource.getMessage(listTitleCode, null, null)); String listPath = wrap(paths.getListPath(entityClass)); SitemapNode listNode = buildNode(getEntityListViewId(entityClass), listTitle, listPath, dashboard); // Details node // FIXME Consider replacing 'entity' with 'application', 'database', etc. String detailsTitle = "#this[" + uncapSimpleName + "].displayName"; String detailsPath = listPath + " + '/' + #this[" + uncapSimpleName + "].id"; SitemapNode detailsNode = buildNode(getCiDetailsViewId(entityClass), detailsTitle, detailsPath, listNode); detailsNode.setShowInDetailsSidebar(true); // Create node String createTitleCode = "entity." + uncapSimpleName + ".lowercase.singular"; log.debug("Looking up message code: {}", createTitleCode); String createTitle = wrap("Create " + messageSource.getMessage(createTitleCode, null, null)); String createPath = wrap(paths.getCreateFormPath(entityClass)); buildNode(getCreateFormId(entityClass), createTitle, createPath, listNode); // Edit node String editTitle = "'Edit ' + #this[entity].displayName"; String editPath = detailsPath + " + '/edit'"; buildNode(getEditFormId(entityClass), editTitle, editPath, detailsNode); }
From source file:org.web4thejob.context.ContextUtil.java
@SuppressWarnings("unchecked") public static <T extends Command> T getDefaultCommand(CommandEnum id, CommandAware owner) { try {//www .jav a2 s .c o m T command = (T) rootContext.getBean(StringUtils.uncapitalize(DefaultCommand.class.getSimpleName()), id, owner); if (id.getValue() != null) { command.setValue(id.getValue()); } return command; } catch (BeanCreationException e) { return null; } }
From source file:net.nan21.dnet.core.presenter.converter.AbstractDsConverter.java
/** * Populate model fields from entity according to mappings. *///w ww . jav a 2 s . c om @Override public void entityToModel(E e, M m, EntityManager em, List<String> fieldNames) throws Exception { Method[] methods = this.getModelClass().getMethods(); int l = methods.length; Map<String, Method> setters = new HashMap<String, Method>(); for (int i = 0; i < l; i++) { Method method = methods[i]; if (method.getName().startsWith("set") && !method.getName().equals("set__clientRecordId__")) { String fieldName = StringUtils.uncapitalize(method.getName().substring(3)); if (fieldNames == null || fieldNames.contains(fieldName)) { setters.put(fieldName, method); } } } Map<String, String> refpaths = this.descriptor.getE2mConv(); entityToModel_(e, m, em, setters, refpaths); }
From source file:com.phoenixnap.oss.ramlapisync.naming.NamingHelper.java
/** * Convert a class name into its restful Resource representation. * * eg. MonitorServiceImpl becomes Monitor * * @param clazz The Class to name/*from www . j a v a2 s . co m*/ * @return The name for this class */ public static String convertClassName(Class<?> clazz) { String convertedName = clazz.getSimpleName(); boolean clean = true; do { Matcher cleaner = CLASS_SUFFIXES_TO_CLEAN.matcher(convertedName); if (cleaner.matches()) { if (cleaner.group(1) != null && cleaner.group(1).length() > 0) { convertedName = cleaner.group(1); } } else { clean = false; } } while (clean); return StringUtils.uncapitalize(convertedName); }
From source file:net.daum.clix.springframework.data.rest.client.repository.RestRepositories.java
private String getResourcePath(Class<?> repositoryInterface) { String path = StringUtils.uncapitalize(repositoryInterface.getSimpleName().replaceAll("Repository", "")); RestResource restResource = repositoryInterface.getAnnotation(RestResource.class); if (restResource != null && StringUtils.hasText(restResource.path())) { path = restResource.path();/*from w ww . j a v a2 s .co m*/ } return path; }
From source file:org.web4thejob.context.ContextUtil.java
@SuppressWarnings("unchecked") public static <T extends Command> T getSubcommand(CommandEnum id, Command command, CommandListener alternateListener) { try {/* w w w . j a v a 2 s.c o m*/ T subcommand = (T) rootContext.getBean( StringUtils.uncapitalize(DefaultSubcommand.class.getSimpleName()), id, command, alternateListener); if (id.getValue() != null) { subcommand.setValue(id.getValue()); } return subcommand; } catch (BeanCreationException e) { return null; } }
From source file:ch.ralscha.extdirectspring.generator.association.AbstractAssociation.java
public static AbstractAssociation createAssociation(ModelAssociation associationAnnotation, ModelBean model, Field field) {//from w w w . j a va 2 s .c o m ModelAssociationType type = associationAnnotation.value(); Class<?> associationClass = associationAnnotation.model(); if (associationClass == Object.class) { associationClass = field.getType(); } AbstractAssociation association; if (type == ModelAssociationType.HAS_MANY) { association = new HasManyAssociation(associationClass); } else if (type == ModelAssociationType.BELONGS_TO) { association = new BelongsToAssociation(associationClass); } else { association = new HasOneAssociation(associationClass); } association.setAssociationKey(field.getName()); if (StringUtils.hasText(associationAnnotation.foreignKey())) { association.setForeignKey(associationAnnotation.foreignKey()); } else if (type == ModelAssociationType.HAS_MANY) { association.setForeignKey(StringUtils.uncapitalize(field.getDeclaringClass().getSimpleName()) + "_id"); } else if (type == ModelAssociationType.BELONGS_TO || type == ModelAssociationType.HAS_ONE) { association.setForeignKey(StringUtils.uncapitalize(associationClass.getSimpleName()) + "_id"); } if (StringUtils.hasText(associationAnnotation.primaryKey())) { association.setPrimaryKey(associationAnnotation.primaryKey()); } else if (type == ModelAssociationType.HAS_MANY && StringUtils.hasText(model.getIdProperty()) && !model.getIdProperty().equals("id")) { association.setPrimaryKey(model.getIdProperty()); } else if (type == ModelAssociationType.BELONGS_TO || type == ModelAssociationType.HAS_ONE) { Model associationModelAnnotation = associationClass.getAnnotation(Model.class); if (associationModelAnnotation != null && StringUtils.hasText(associationModelAnnotation.idProperty()) && !associationModelAnnotation.idProperty().equals("id")) { association.setPrimaryKey(associationModelAnnotation.idProperty()); } } if (type == ModelAssociationType.HAS_MANY) { HasManyAssociation hasManyAssociation = (HasManyAssociation) association; if (StringUtils.hasText(associationAnnotation.setterName())) { LogFactory.getLog(ModelGenerator.class) .warn(getWarningText(field, association.getType(), "setterName")); } if (StringUtils.hasText(associationAnnotation.getterName())) { LogFactory.getLog(ModelGenerator.class) .warn(getWarningText(field, association.getType(), "getterName")); } if (associationAnnotation.autoLoad()) { hasManyAssociation.setAutoLoad(true); } if (StringUtils.hasText(associationAnnotation.name())) { hasManyAssociation.setName(associationAnnotation.name()); } else { hasManyAssociation.setName(field.getName()); } } else if (type == ModelAssociationType.BELONGS_TO) { BelongsToAssociation belongsToAssociation = (BelongsToAssociation) association; if (StringUtils.hasText(associationAnnotation.setterName())) { belongsToAssociation.setSetterName(associationAnnotation.setterName()); } else { belongsToAssociation.setSetterName("set" + StringUtils.capitalize(field.getName())); } if (StringUtils.hasText(associationAnnotation.getterName())) { belongsToAssociation.setGetterName(associationAnnotation.getterName()); } else { belongsToAssociation.setGetterName("get" + StringUtils.capitalize(field.getName())); } if (associationAnnotation.autoLoad()) { LogFactory.getLog(ModelGenerator.class) .warn(getWarningText(field, association.getType(), "autoLoad")); } if (StringUtils.hasText(associationAnnotation.name())) { LogFactory.getLog(ModelGenerator.class).warn(getWarningText(field, association.getType(), "name")); } } else { HasOneAssociation hasOneAssociation = (HasOneAssociation) association; if (StringUtils.hasText(associationAnnotation.setterName())) { hasOneAssociation.setSetterName(associationAnnotation.setterName()); } else { hasOneAssociation.setSetterName("set" + StringUtils.capitalize(field.getName())); } if (StringUtils.hasText(associationAnnotation.getterName())) { hasOneAssociation.setGetterName(associationAnnotation.getterName()); } else { hasOneAssociation.setGetterName("get" + StringUtils.capitalize(field.getName())); } if (associationAnnotation.autoLoad()) { LogFactory.getLog(ModelGenerator.class) .warn(getWarningText(field, association.getType(), "autoLoad")); } if (StringUtils.hasText(associationAnnotation.name())) { LogFactory.getLog(ModelGenerator.class).warn(getWarningText(field, association.getType(), "name")); } } return association; }