Skip to content

Instantly share code, notes, and snippets.

@zygisx
Created November 4, 2011 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zygisx/1340415 to your computer and use it in GitHub Desktop.
Save zygisx/1340415 to your computer and use it in GitHub Desktop.
Pagrindines klases klonavimas
@Override
public Customs clone() throws CloneNotSupportedException {
Customs result = (Customs) super.clone();
/* clone all officers */
result.officers = (ArrayList<CustomsOfficer>) officers.clone();
for (CustomsOfficer o : result.officers) {
o = o.clone();
}
/* clone all inspections */
result.inspections = (ArrayList<Inspection>) inspections.clone();
for (Inspection i : result.inspections) {
i = i.clone();
/* link all officers in inspection with correct officer from Customs ArrayList */
for (CustomsOfficer c : result.officers ) {
if (i.getOfficer().getPersonalID().equals(c.getPersonalID())) {
i.setOfficer(c);
break;
}
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment