/** * 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); }
/** * 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(); } }
/** * Return the method suffixes for a given property name. The default implementation * uses JavaBean conventions with additional support for properties of the form 'xY' * where the method 'getXY()' is used in preference to the JavaBean convention of * 'getxY()'. */ protected String[] getPropertyMethodSuffixes(String propertyName) { String suffix = getPropertyMethodSuffix(propertyName); if (suffix.length() > 0 && Character.isUpperCase(suffix.charAt(0))) { return new String[] {suffix}; } return new String[] {suffix, StringUtils.capitalize(suffix)}; }
@Override public boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException { if (target == null) { return false; } Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass()); if (type.isArray()) { return false; } if (this.member instanceof Method) { Method method = (Method) this.member; String getterName = "get" + StringUtils.capitalize(name); if (getterName.equals(method.getName())) { return true; } getterName = "is" + StringUtils.capitalize(name); return getterName.equals(method.getName()); } else { Field field = (Field) this.member; return field.getName().equals(name); } }
@Override protected String getBeanClassName(Element element) { String elementName = Conventions.attributeNameToPropertyName( element.getLocalName()); return RedissonNamespaceParserSupport.IMPL_CLASS_PATH_PREFIX + StringUtils.capitalize(elementName); }
@Override protected String getBeanClassName(Element element) { String elementName = Conventions.attributeNameToPropertyName( element.getLocalName()); return RedissonNamespaceParserSupport.IMPL_CLASS_PATH_PREFIX + StringUtils.capitalize(elementName); }
@Nullable PropertyDescriptor getPropertyDescriptor(String name) { PropertyDescriptor pd = this.propertyDescriptorCache.get(name); if (pd == null && StringUtils.hasLength(name)) { // Same lenient fallback checking as in Property... pd = this.propertyDescriptorCache.get(StringUtils.uncapitalize(name)); if (pd == null) { pd = this.propertyDescriptorCache.get(StringUtils.capitalize(name)); } } return (pd == null || pd instanceof GenericTypeAwarePropertyDescriptor ? pd : buildGenericTypeAwarePropertyDescriptor(getBeanClass(), pd)); }
@Override protected Class<?> getBeanClass(Element element) { String elementName = Conventions.attributeNameToPropertyName( element.getLocalName()); try { return Class.forName(RedissonNamespaceParserSupport.API_CLASS_PATH_PREFIX + (StringUtils.capitalize(FAIL_LOCK.equals(elementName) ? "lock" : elementName))); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException(ex); } }
@Override protected Class<?> getBeanClass(Element element) { String elementName = Conventions.attributeNameToPropertyName( element.getLocalName()); try { return Class.forName(RedissonNamespaceParserSupport.API_CLASS_PATH_PREFIX + (StringUtils.capitalize(FAIL_LOCK.equals(elementName) ? "lock" : elementName))); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException(ex); } }
public CheckMethod(Descriptor descriptor, String fieldName) { this.descriptor = descriptor; this.capitalizedFieldName = StringUtils.capitalize(fieldName); method = ReflectionUtils.getPublicMethodNamed(descriptor.getClass(), "doCheck" + capitalizedFieldName); if(method !=null) { names = new ArrayList<String>(); findParameters(method); } else { names = null; } }
/** * Computes the auto-completion setting */ public void calcAutoCompleteSettings(String field, Map<String,Object> attributes) { String capitalizedFieldName = StringUtils.capitalize(field); String methodName = "doAutoComplete" + capitalizedFieldName; Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName); if(method==null) return; // no auto-completion attributes.put("autoCompleteUrl", String.format("%s/%s/autoComplete%s", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName)); }
@Nullable private Field getField() { String name = getName(); if (!StringUtils.hasLength(name)) { return null; } Field field = null; Class<?> declaringClass = declaringClass(); if (declaringClass != null) { field = ReflectionUtils.findField(declaringClass, name); if (field == null) { // Same lenient fallback checking as in CachedIntrospectionResults... field = ReflectionUtils.findField(declaringClass, StringUtils.uncapitalize(name)); if (field == null) { field = ReflectionUtils.findField(declaringClass, StringUtils.capitalize(name)); } } } return field; }
/** * Computes the list of other form fields that the given field depends on, via the doFillXyzItems method, * and sets that as the 'fillDependsOn' attribute. Also computes the URL of the doFillXyzItems and * sets that as the 'fillUrl' attribute. */ public void calcFillSettings(String field, Map<String,Object> attributes) { String capitalizedFieldName = StringUtils.capitalize(field); String methodName = "doFill" + capitalizedFieldName + "Items"; Method method = ReflectionUtils.getPublicMethodNamed(getClass(), methodName); if(method==null) throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName)); // build query parameter line by figuring out what should be submitted List<String> depends = buildFillDependencies(method, new ArrayList<String>()); if (!depends.isEmpty()) attributes.put("fillDependsOn",Util.join(depends," ")); attributes.put("fillUrl", String.format("%s/%s/fill%sItems", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName)); }
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); }
@Test public void testCapitalize() { String capitalized = "i am not capitalized"; assertEquals("I am not capitalized", StringUtils.capitalize(capitalized)); }
private void parseAddressTypes(Element element, String addressType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) { BeanComponentDefinition invoker = helper.invoker(element, parserContext.getContainingComponent().getName(), "add" + StringUtils.capitalize(addressType), new String[]{element.getAttribute("value")}, parserContext); String id = invoker.getName(); redissonDef.addDependsOn(id); }
private void parseAddressTypes(Element element, String addressType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) { BeanComponentDefinition invoker = helper.invoker(element, parserContext.getContainingComponent().getName(), "add" + StringUtils.capitalize(addressType), new String[]{element.getAttribute("value")}, parserContext); String id = invoker.getName(); redissonDef.addDependsOn(id); }
String propertyName = pv.getName(); Class<?> propertyType = BeanUtils.findPropertyType(propertyName, interfaces); String setterName = "set" + StringUtils.capitalize(propertyName); Signature signature = new Signature(setterName, Type.VOID_TYPE, new Type[] {Type.getType(propertyType)}); maker.add(signature, new Type[0]);
private void parseConfigTypes(Element element, String configType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) { BeanDefinitionBuilder builder = helper.createBeanDefinitionBuilder(element, parserContext, null); //Use factory method on the Config bean AbstractBeanDefinition bd = builder.getRawBeanDefinition(); bd.setFactoryMethodName("use" + StringUtils.capitalize(configType)); bd.setFactoryBeanName(parserContext.getContainingComponent().getName()); String id = parserContext.getReaderContext().generateBeanName(bd); helper.registerBeanDefinition(builder, id, helper.parseAliase(element), parserContext); helper.parseAttributes(element, parserContext, builder); redissonDef.addDependsOn(id); parseChildElements(element, id, null, redissonDef, parserContext); parserContext.getDelegate().parseQualifierElements(element, bd); }
private void parseConfigTypes(Element element, String configType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) { BeanDefinitionBuilder builder = helper.createBeanDefinitionBuilder(element, parserContext, null); //Use factory method on the Config bean AbstractBeanDefinition bd = builder.getRawBeanDefinition(); bd.setFactoryMethodName("use" + StringUtils.capitalize(configType)); bd.setFactoryBeanName(parserContext.getContainingComponent().getName()); String id = parserContext.getReaderContext().generateBeanName(bd); helper.registerBeanDefinition(builder, id, helper.parseAliase(element), parserContext); helper.parseAttributes(element, parserContext, builder); redissonDef.addDependsOn(id); parseChildElements(element, id, null, redissonDef, parserContext); parserContext.getDelegate().parseQualifierElements(element, bd); }