方法不可用
有一个 CustomerData 类,其中包含各种字段以及这些字段的 set/get 方法。
class CustomerData{
int ssn;
int homePhone;
int officePhone;
String product;
String sameAsPrev=null;
// set/get methods
}
我需要用客户类替换此类。客户类位于 jar 文件中。因此我无法修改。 CustomerData 的某些字段在 Customer 类中不可用,我需要在 Customer 对象上调用这些字段。
有一个限制,我不能添加任何类,只能用 Customer 替换 CustomerData 类。
在控制器中调用字段上的 set 方法后,他们使用映射来存储数据。
我怎样才能获得这些字段的值。
请给一些建议...
There is a class CustomerData which contains various fields and set/get method for those fields.
class CustomerData{
int ssn;
int homePhone;
int officePhone;
String product;
String sameAsPrev=null;
// set/get methods
}
I need to replace this class with class Customer. Customer class is in jar file. hence i can't modified. some fields of CustomerData is not available in Customer class and i need to call those fields on Customer Object.
there is a restriction that i can't add any class but just to replace CustomerData class with Customer.
in Controller after calling set methods on field they used map to store the data.
how can i get the values of those fields.
please give some suggestions...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的类中但不在 Customer 类中的字段是必填字段,那么您有两个选择:
选项 1(isa,扩展)
用您的类扩展客户类。
选项 2(hasa、包含):
将 Customer 类包含在您的类中。
选项 3(奖励选项):
创建一个类,其中包含所需的字段,但这些字段不在 Customer 类中。
If the fields that are in your class but, which are not in the Customer class are mandatory, then you have two options:
Option 1 (isa, extends)
Extend the Customer class with your class.
Option 2 (hasa, contains):
Contain the Customer class in your class.
Option 3 (bonus option):
Create a class with the fields that are required but, which are not in the Customer class.