class CreateKerberosConfigRequestToKerberosConfigConverter {

    public KerberosConfig convert(CreateKerberosConfigRequest request) {
        if (request == null || !KerberosRequestValidator.isValid(request)) {
            throw new BadRequestException("Improper CreateKerberosConfigRequest!");
        }
        KerberosConfig kerberos;
        if (request.getFreeIpa() != null) {
            kerberos = convertFreeIpa(request.getFreeIpa());
        } else if (request.getActiveDirectory() != null) {
            kerberos = convertActiveDirectory(request.getActiveDirectory());
        } else if (request.getMit() != null) {
            kerberos = convertMit(request.getMit());
        } else {
            throw new BadRequestException("Unable to determine Kerberos Configuration since none of them are provided in the request!");
        }
        kerberos.setName(request.getName());
        kerberos.setDescription(request.getDescription());
        kerberos.setEnvironmentCrn(request.getEnvironmentCrn());
        return kerberos;
    }

}