private String propertyNameFor(Method method) { return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); }
private String stripGetPrefix(Method m) { String n = m.getName(); if(n.startsWith("get")) n = Introspector.decapitalize(n.substring(3)); return n; }
/** * Convert names like "abcDefGhi" to "abc def ghi". */ private String splitName(String url) { StringBuilder buf = new StringBuilder(url.length()+5); for(String token : url.split("(?<=[a-z])(?=[A-Z])")) { if(buf.length()>0) buf.append(' '); buf.append(Introspector.decapitalize(token)); } return buf.toString(); }
/** * Return the short string name of a Java class in uncapitalized JavaBeans * property format. Strips the outer class name in case of an inner class. * @param clazz the class * @return the short name rendered in a standard JavaBeans property format * @see java.beans.Introspector#decapitalize(String) */ public static String getShortNameAsProperty(Class<?> clazz) { String shortName = getShortName(clazz); int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR); shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName); return Introspector.decapitalize(shortName); }
/** * Derive a default bean name from the given bean definition. * <p>The default implementation simply builds a decapitalized version * of the short class name: e.g. "mypackage.MyJdbcDao" -> "myJdbcDao". * <p>Note that inner classes will thus have names of the form * "outerClassName.InnerClassName", which because of the period in the * name may be an issue if you are autowiring by name. * @param definition the bean definition to build a bean name for * @return the default bean name (never {@code null}) */ protected String buildDefaultBeanName(BeanDefinition definition) { String beanClassName = definition.getBeanClassName(); Assert.state(beanClassName != null, "No bean class name set"); String shortClassName = ClassUtils.getShortName(beanClassName); return Introspector.decapitalize(shortClassName); }
private static String getPropertyName(String methodName, int prefixLength) { String result = methodName.substring(prefixLength); if (result.length() == 0) return null; return Introspector.decapitalize(result); }
private static String getPermissionsTableName(Class<?> owner, Class<?> property) { String propertyName = property.getSimpleName(); if (propertyName.equals("ManagedUser")) { propertyName = "User"; } return "tc_" + Introspector.decapitalize(owner.getSimpleName()) + "_" + Introspector.decapitalize(propertyName); }
private static void logLinkAction(String action, long userId, Class<?> owner, long ownerId, Class<?> property, long propertyId) { LOGGER.info(String.format( PATTERN_LINK, userId, action, Introspector.decapitalize(owner.getSimpleName()), ownerId, Introspector.decapitalize(property.getSimpleName()), propertyId)); }
/** * Given the class, list up its {@link PropertyType}s from its public fields/getters. */ private Map<String, PropertyType> buildPropertyTypes(Class<?> clazz) { Map<String, PropertyType> r = new HashMap<String, PropertyType>(); for (Field f : clazz.getFields()) r.put(f.getName(),new PropertyType(f)); for (Method m : clazz.getMethods()) if(m.getName().startsWith("get")) r.put(Introspector.decapitalize(m.getName().substring(3)),new PropertyType(m)); return r; }
private static String getObjectsTableName(Class<?> clazz) { String result = "tc_" + Introspector.decapitalize(clazz.getSimpleName()); // Add "s" ending if object name is not plural already if (!result.endsWith("s")) { result += "s"; } return result; }
public static String getPropertyName(Method method) { String methodName = method.getName(); if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0) { return Introspector.decapitalize(methodName.substring(3)); } else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0) { return Introspector.decapitalize(methodName.substring(2)); } else if (methodName.matches("^(set).*") && method.getParameterTypes().length == 1) { return Introspector.decapitalize(methodName.substring(3)); } return null; }
private String propertyNameFor(Method method) { return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); }
/** * Return the short string name of a Java class in uncapitalized JavaBeans * property format. Strips the outer class name in case of an inner class. * @param clazz the class * @return the short name rendered in a standard JavaBeans property format * @see java.beans.Introspector#decapitalize(String) */ public static String getShortNameAsProperty(Class<?> clazz) { String shortName = getShortName(clazz); int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR); shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName); return Introspector.decapitalize(shortName); }
/** * Derive a default bean name from the given bean definition. * <p>The default implementation simply builds a decapitalized version * of the short class name: e.g. "mypackage.MyJdbcDao" -> "myJdbcDao". * <p>Note that inner classes will thus have names of the form * "outerClassName.InnerClassName", which because of the period in the * name may be an issue if you are autowiring by name. * @param definition the bean definition to build a bean name for * @return the default bean name (never {@code null}) */ protected String buildDefaultBeanName(BeanDefinition definition) { String beanClassName = definition.getBeanClassName(); Assert.state(beanClassName != null, "No bean class name set"); String shortClassName = ClassUtils.getShortName(beanClassName); return Introspector.decapitalize(shortClassName); }
/** * Derives the name of a property from the given set method. * * @param m the method * @return the corresponding property name */ private String propertyName(final Method m) { final String methodName = m.getName().substring( getWriteMethodPrefix().length()); return (methodName.length() > 1) ? Introspector.decapitalize(methodName) : methodName .toLowerCase(Locale.ENGLISH); }
/** * Derives the name of a property from the given set method. * * @param m the method * @return the corresponding property name */ private String propertyName(final Method m) { final String methodName = m.getName().substring( getWriteMethodPrefix().length()); return (methodName.length() > 1) ? Introspector.decapitalize(methodName) : methodName .toLowerCase(Locale.ENGLISH); }
public static String getShortNameAsProperty(Class<?> clazz) { String shortName = getShortName((Class) clazz); int dotIndex = shortName.lastIndexOf(46); shortName = dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName; return Introspector.decapitalize(shortName); }
public EjbRefElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); EJB resource = ae.getAnnotation(EJB.class); String resourceBeanName = resource.beanName(); String resourceName = resource.name(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } Class<?> resourceType = resource.beanInterface(); if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.beanName = resourceBeanName; this.name = resourceName; this.lookupType = resourceType; this.mappedName = resource.mappedName(); }
public WebServiceRefElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); WebServiceRef resource = ae.getAnnotation(WebServiceRef.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = resourceName; this.elementType = resourceType; if (Service.class.isAssignableFrom(resourceType)) { this.lookupType = resourceType; } else { this.lookupType = resource.value(); } this.mappedName = resource.mappedName(); this.wsdlLocation = resource.wsdlLocation(); }
public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }