All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.gov.di.ipv.cri.common.library.service.PersonIdentityDetailedBuilder Maven / Gradle / Ivy

The newest version!
package uk.gov.di.ipv.cri.common.library.service;

import uk.gov.di.ipv.cri.common.library.domain.personidentity.Address;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.BirthDate;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.DrivingPermit;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.Name;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.Passport;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.PersonIdentityDetailed;
import uk.gov.di.ipv.cri.common.library.domain.personidentity.SocialSecurityRecord;

import java.util.List;

public class PersonIdentityDetailedBuilder {
    /* Builder approach similar in intent to PersonIdentityDetailedFactory
    A way of constructing PersonIdentityDetailed where some components are not needed
    Avoids cris needing to provide null lists for parameters they don't need.
    Avoids a growing chain of lists being added to the public constructor and also
    useful in when used in conjunction with AuditContext to build out AuditEvent
    where names, birthDates may be desirable as nulls
    */
    private PersonIdentityDetailedBuilder() {
        throw new IllegalStateException("Instantiation is not valid for this class.");
    }

    public static Builder builder(List names, List birthDates) {
        return new Builder(names, birthDates);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {

        private List socialSecurityRecords;
        private List names;
        private List birthDates;
        private List
addresses; private List drivingPermits; private List passports; private Builder() { this(null, null); } private Builder(List names, List birthDates) { this.names = names; this.birthDates = birthDates; } public Builder withAddresses(List
addresses) { this.addresses = addresses; return this; } public Builder withDrivingPermits(List drivingPermits) { this.drivingPermits = drivingPermits; return this; } public Builder withPassports(List passports) { this.passports = passports; return this; } public Builder withNino(List socialSecurityRecords) { this.socialSecurityRecords = socialSecurityRecords; return this; } @SuppressWarnings("deprecation") public PersonIdentityDetailed build() { return new PersonIdentityDetailed( names, birthDates, addresses, drivingPermits, passports, socialSecurityRecords); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy