Convert single char in String to lower case

后端 未结 7 1750
孤独总比滥情好
孤独总比滥情好 2021-01-17 10:15

I like to \'guess\' attribute names from getter methods. So \'getSomeAttribute\' shall be converted to \'someAttribute\'.

Usually I do something like



        
7条回答
  •  隐瞒了意图╮
    2021-01-17 11:16

    Have a look at the JavaBeans API:

    BeanInfo info = Introspector.getBeanInfo(bean
           .getClass(), Object.class);
    for (PropertyDescriptor propertyDesc : info
           .getPropertyDescriptors()) {
      String name = propertyDesc.getName();
    }
    

    Also see decapitalize.

提交回复
热议问题