I am currently having below parent child relation java objects JCL > JOB > steps > step > dd
Class looks like below
public class Jcl {
Private Job job;
}
public class Job {
private String jobname;
//Below is direct property of job object
private List<Jobparam> jobparam;
//Below is child object of the job object
private List<Step> step;
}
public class Step {
private String stepname;
//Below is direct property of step object
private List<Stepparam> stepparam;
//Below is child object of the step object
private List<Ddstatement> ddstatement;
}
public class Stepparam {
private String name;
private String value;
}
public class Jobparam{
private String name;
private String value;
}
I am using getters and setters to create objects with new instance of each object.
Job job = new Job();
ArrayList<Jobparam> myList = new ArrayList<Jobparam>();
job.getJobparam().addAll(myList);
Step step = new Step();
ArrayList<Stepparam> myList = new ArrayList<Stepparam>();
jcl.getJob().getStep().add(step);
And also jobparam and stepparam have same property.(I want to reuse but donno how) I feel I am creating each new object every time and this long coding can be avoided by java design pattern. Any suggestion how should I proceed to make simple code would be helpful.
Aucun commentaire:
Enregistrer un commentaire