如何计算类中存在的字符串对象数
我有一个具有字符串变量数量的类,我想计算所有字符串变量。
public class Account {
//objects
// private String pageAuthenticationNavBar = "xpath:=//div[@class='ng-binding' and contains(text(),'Account Authentication')]";
private String listAuthMethod = "id:=account-authentication-authentication-methods";
private String btnContinue = "xpath:=//button[@id='account-authentication-continue']";
private String btnSkip = "xpath:=//*[contains(text(), 'Send OTP')]/..//*[contains(text(),'Skip')]";
private String btnSkipNoSMS = "xpath:=//*[@class='skip-sms-auth-container']//*[contains(text(),'Skip Authentication')]";
private String formAccountAuthentication = "xpath:=//*[@class='global-container authentication-process']";
private String txtChooseSubscriber = "xpath:=//div[contains(text(), 'Choose Subscriber')]";
private String txtSubscriberByIndex = "xpath:=(//*[contains(@class,'flex subscriber-item-inside-list')]//*[@class='subscriber-icon'])[INDEX]";
private String btnSendOtp = "xpath:=//button[starts-with(@class,'auth-continue-button')]"; //id:=account-authentication-send-otp
private String txtOtp = "id:=smsCodeInput";
}
是否有任何方法,有什么逻辑来计算所有字符串对象?
I have one class that has number of a String variable, I want to count all String variables.
public class Account {
//objects
// private String pageAuthenticationNavBar = "xpath:=//div[@class='ng-binding' and contains(text(),'Account Authentication')]";
private String listAuthMethod = "id:=account-authentication-authentication-methods";
private String btnContinue = "xpath:=//button[@id='account-authentication-continue']";
private String btnSkip = "xpath:=//*[contains(text(), 'Send OTP')]/..//*[contains(text(),'Skip')]";
private String btnSkipNoSMS = "xpath:=//*[@class='skip-sms-auth-container']//*[contains(text(),'Skip Authentication')]";
private String formAccountAuthentication = "xpath:=//*[@class='global-container authentication-process']";
private String txtChooseSubscriber = "xpath:=//div[contains(text(), 'Choose Subscriber')]";
private String txtSubscriberByIndex = "xpath:=(//*[contains(@class,'flex subscriber-item-inside-list')]//*[@class='subscriber-icon'])[INDEX]";
private String btnSendOtp = "xpath:=//button[starts-with(@class,'auth-continue-button')]"; //id:=account-authentication-send-otp
private String txtOtp = "id:=smsCodeInput";
}
Is there any method, any logic for counting all the String objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如F1SH在评论中提到的那样,您可以使用以下反射:
输出:
As f1sh mentioned in comment, you can use reflection something like below:
Output: