java - Java reflection - get getter method with different name
问题描述
Is there any way I can get the getter
method of a field, which is having different name from the usual standards?
class Employee {
private String name;
private String dept;
public String getTheName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTheDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
}
I know using reflection we can get the getter
method of a field if the getter
method is following the usual standard.
Example:
- name ==> getName
- dept ==> getDept
But in our project, we are having a different convention than usual.
Thanks in advance.
解决方案
推荐阅读
- reactjs - 更新 mongoose 模式后,如何向多个文档添加新字段?
- ios - 点击 MGLPolygon 应该将点击转发到相同坐标的 MGLAnnotation
- android - 以反向横向模式锁定我的 android 应用程序
- javascript - 如何使用 Firestore 从静态 SVG 文件创建具有动态链接的图像映射
- api - Algolia 自动完成 - 如何从自动完成建议中删除“行政”市/区
- android - 我们可以停止一个 groupview 在触摸它时不显示它的 childList(对于某些特定情况)
- c++ - vector::insert() 中的有效位置如何?
- c# - 获取与具体用户对应的用户角色
- c# - 是否可以使用异步任务永久更改布尔值?
- sql-server - 将字符串数据类型日期值转换为日期格式dd-mm-yyyy