使用Dozer框架在java中进行对象映射
我正在使用 Dozer 框架在 java 中进行对象映射。
现在我因为以下问题而陷入困境:
以下是我的课程:
public class BaseQuestion
{
public String question = "";
public String answer = "";
/**
* Getter for question
*/
public String getQuestion()
{
return question;
}
/**
* @Setter for question
*/
public void setQuestion(String question)
{
this.question = question;
}
/**
* Getter for answer
*/
public String getAnswer()
{
return answer;
}
/**
* @Setter for answer
*/
public void setAnswer(String answer)
{
this.answer = answer;
}
}
public class QuestionsMap
{
Question[] question;
public void setQuestion(Question[] question)
{
this.question = question;
}
public Question[] getQuestion()
{
return this.question;
}
}
In the above classes I have to map QuestionsMap class with a HashMap as below:
Map<String,String> questionsMap=new HashMap<String,String>();
BaseQuestion[] question=QuestionsMap.getQuestion();
questionsMap.put(question[0].getQuestion(),question[0].getAnswer());
questionsMap.put(question[1].getQuestion(),question[1].getAnswer());
questionsMap.put(question[2].getQuestion(),question[2].getAnswer());
questionsMap.put(question[3].getQuestion(),question[3].getAnswer());
任何人都可以建议我如何使用推土机框架实现它。
谢谢,
纳伦德拉
I am using Dozer framework for my object mapping in java.
Now I got stuck because of the following problem:
Following are my classes:
public class BaseQuestion
{
public String question = "";
public String answer = "";
/**
* Getter for question
*/
public String getQuestion()
{
return question;
}
/**
* @Setter for question
*/
public void setQuestion(String question)
{
this.question = question;
}
/**
* Getter for answer
*/
public String getAnswer()
{
return answer;
}
/**
* @Setter for answer
*/
public void setAnswer(String answer)
{
this.answer = answer;
}
}
public class QuestionsMap
{
Question[] question;
public void setQuestion(Question[] question)
{
this.question = question;
}
public Question[] getQuestion()
{
return this.question;
}
}
In the above classes I have to map QuestionsMap class with a HashMap as below:
Map<String,String> questionsMap=new HashMap<String,String>();
BaseQuestion[] question=QuestionsMap.getQuestion();
questionsMap.put(question[0].getQuestion(),question[0].getAnswer());
questionsMap.put(question[1].getQuestion(),question[1].getAnswer());
questionsMap.put(question[2].getQuestion(),question[2].getAnswer());
questionsMap.put(question[3].getQuestion(),question[3].getAnswer());
Can any one suggest how can I acheive it using dozer framework.
Thanks,
Narendra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要使用推土机???这是您要找的吗:
Why do you want to use dozer ??? Is this what you are looking for: