这是会员:
public class Member implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private MemberPK id;
@Column(name="BUSINESS_UNIT", nullable=true, length=2)
private char businessUnit;
@Column(name="DELETED_IND", nullable=false, length=1)
private char deletedInd;
@Column(name = "FIRSTNAME",length=14)
private String firstname;
@Column(name = "LASTNAME", length = 14)
}
这是资格:
public class Eligibility implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private MemberSpanPK id;
@Column(name = "AFF_NBR", nullable=false, length=16)
private String affNbr;
@Column(name = "BUSINESS_UNIT", length = 2)
private Character businessUnit;
@Column(name = "CARRIER", nullable=true, length = 2)
private char carrier;
@Column(name="DELETED_IND", nullable=false, length=1)
}
这是我想把前两个对象放入的第三个对象。
public class MemberData {
// Members
private String membernbr;
private String medicaidNbr;
private String namefirst;
private String namelast;
//Eligibility
private String memberpcp;
private String bu;
private String carrier;
private String deletedInd;
}
答案 0 :(得分:0)
带有访问器和更改器(getter和setter)的简单域驱动方法怎么样?
MemberData memberData = new MemberData();
memberData.copyMember(/* Member instance */); //Inside get from member and set at memberData.
memberData.copyEligibility(/* Eligibility instance*/); //Inside get from eligibility and set at memberData.
您可以运行一些顶级循环以获得成员的相应资格数据,并创建MemberData
实例。
****编辑****
请参阅示例对象和代码示例...
public class Member implements Serializable {
public MemberPK getId() {
return id;
}
public void setId(MemberPK id) {
this.id = id;
}
public char getBusinessUnit() {
return businessUnit;
}
public void setBusinessUnit(char businessUnit) {
this.businessUnit = businessUnit;
}
public char getDeletedInd() {
return deletedInd;
}
public void setDeletedInd(char deletedInd) {
this.deletedInd = deletedInd;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
private static final long serialVersionUID = 1L;
private MemberPK id;
private char businessUnit;
private char deletedInd;
private String firstname;
}
public class Eligibility implements Serializable {
private static final long serialVersionUID = 1L;
private MemberSpanPK id;
private String affNbr;
private Character businessUnit;
private char carrier;
private String deleteInd;
public MemberSpanPK getId() {
return id;
}
public void setId(MemberSpanPK id) {
this.id = id;
}
public String getAffNbr() {
return affNbr;
}
public void setAffNbr(String affNbr) {
this.affNbr = affNbr;
}
public Character getBusinessUnit() {
return businessUnit;
}
public void setBusinessUnit(Character businessUnit) {
this.businessUnit = businessUnit;
}
public char getCarrier() {
return carrier;
}
public void setCarrier(char carrier) {
this.carrier = carrier;
}
public String getDeleteInd() {
return deleteInd;
}
public void setDeleteInd(String deleteInd) {
this.deleteInd = deleteInd;
}
}
public class MemberPK {
private String memberNbr;
public String getMemberNbr() {
return memberNbr;
}
public void setMemberNbr(String memberNbr) {
this.memberNbr = memberNbr;
}
}
public class MemberSpanPK {
private String memberNbr;
public String getMemberNbr() {
return memberNbr;
}
public void setMemberNbr(String memberNbr) {
this.memberNbr = memberNbr;
}
}
public class EligibilityVO {
//Eligibility
private String memberpcp;
private String bu;
private String carrier;
private String deletedInd;
public String getMemberpcp() {
return memberpcp;
}
public void setMemberpcp(String memberpcp) {
this.memberpcp = memberpcp;
}
public String getBu() {
return bu;
}
public void setBu(String bu) {
this.bu = bu;
}
public String getCarrier() {
return carrier;
}
public void setCarrier(String carrier) {
this.carrier = carrier;
}
public String getDeletedInd() {
return deletedInd;
}
public void setDeletedInd(String deletedInd) {
this.deletedInd = deletedInd;
}
}
public class MemberData {
// Members
private String membernbr;
private String medicaidNbr;
private String namefirst;
private String namelast;
private List<EligibilityVO> eligibilities;
public List<EligibilityVO> getEligibilities() {
return eligibilities;
}
public void setEligibilities(List<EligibilityVO> eligibilities) {
this.eligibilities = eligibilities;
}
public void addEligibilities(EligibilityVO eligibility) {
if(null == this.eligibilities) {
this.eligibilities = new ArrayList<EligibilityVO>();
}
this.eligibilities.add(eligibility);
}
public String getMembernbr() {
return membernbr;
}
public void setMembernbr(String membernbr) {
this.membernbr = membernbr;
}
public String getMedicaidNbr() {
return medicaidNbr;
}
public void setMedicaidNbr(String medicaidNbr) {
this.medicaidNbr = medicaidNbr;
}
public String getNamefirst() {
return namefirst;
}
public void setNamefirst(String namefirst) {
this.namefirst = namefirst;
}
public String getNamelast() {
return namelast;
}
public void setNamelast(String namelast) {
this.namelast = namelast;
}
}
用于合并数据的示例类......
public class MergeData {
public static void main(String[] args) {
List<Member> members = new ArrayList<Member>();//Your service level member list here
List<Eligibility> eligibilities = new ArrayList<Eligibility>();//Your service level eligibility list here
List<MemberData> memberDatas = new ArrayList<MemberData>();
for (Member member : members) {
MemberData memberData = new MemberData();
for (Eligibility eligibility : eligibilities) {
if(member.getId().getMemberNbr() == eligibility.getId().getMemberNbr()) {
EligibilityVO eliVo = new EligibilityVO();
eliVo.setBu(eligibility.getAffNbr());
//set others
memberData.addEligibilities(eliVo);
}
}
memberData.setNamefirst(member.getFirstname());
//Set others
}
}
}
希望这有帮助。