package net.sourceforge.fenixedu.domain; import java.util.Collection; import net.sourceforge.fenixedu.dataTransferObject.person.PersonBean.ResidenceBean; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import com.linkare.commons.metainfo.Linkare; /** * * @author Paulo Zenida - Linkare TI * */ @Linkare(author = "Paulo Zenida") public class PersonResidence extends PersonResidence_Base { public PersonResidence(final Person person) { super(); setRootDomainObject(RootDomainObject.getInstance()); checkPerson(person); super.setPerson(person); } private void checkPerson(final Person person) { if (person == null) { throw new DomainException("error.person.cannot.be.null"); } } public final void edit(final ResidenceBean residenceBean) { checkParameters(residenceBean.getCountry(), residenceBean.getDistrict(), residenceBean.getDistrictSubdivision(), residenceBean.getParish()); setCountry(residenceBean.getCountry()); setDistrict(residenceBean.getDistrict()); setDistrictSubdivision(residenceBean.getDistrictSubdivision()); setParish(residenceBean.getParish()); } private void checkParameters(final Country country, final String district, final String districtSubdivision, final String parish) { if (country == null) { throw new DomainException("error.country.cannot.be.null"); } if (district == null) { throw new DomainException("error.district.cannot.be.null"); } if (districtSubdivision == null) { throw new DomainException("error.districtSubdivision.cannot.be.null"); } } // utility static methods public static final Collection readAll() { return RootDomainObject.getInstance().getResidences(); } }