Mình sử dụng một trường có annotation @EzyAutoBind ở trong constructor của class thì bị NullException. Có cách nào để workaround không nhỉ mọi người?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nếu lớp của anh chỉ có các field là các singleton khác thì anh có thể dùng kiểu này:
Còn nếu lớp của anh chứa các field khác không phải là singleton thì anh bắt buộc sử dụng @EzyAutoBind anh ạ:
Thank em. Hoặc là anh có thể sử dụng Factory design pattern để sử dụng No Args constructor nhỉ? Sau đó thì initialize các field sử dụng method khác sau, như vậy lúc này các @EzyAutoBind field đều được assign value rồi.
Em chưa hiểu ý anh lắm, nhưng nếu cái factory đó là singleton thì hoàn toàn có thể anh ạ.