package com.airlock.iam.techclientreg.domain.model.step;

import com.airlock.iam.base.api.domain.model.identity.Identity;
import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapificationUtils;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.flow.api.domain.model.step.StepResultData;
import com.airlock.iam.oauth2.api.domain.model.OAuth2ClientId;
import com.airlock.iam.oauth2.api.domain.model.OAuth2ClientSecret;
import com.airlock.iam.oauth2.api.domain.model.OAuth2Scope;
import com.airlock.iam.techclient.api.domain.model.TechnicalClient;
import com.airlock.iam.techclient.domain.model.identity.TechClientIdentityFactory;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import lombok.NonNull;
import org.apache.commons.lang3.LocaleUtils;

public final class OAuth2ClientRegistrationResponseData implements StepResultData {
   private static final String CLIENT_ID_KEY = "clientId";
   private static final String TECH_CLIENT_ID_KEY = "techClientId";
   private static final String CLIENT_SECRET_KEY = "clientSecret";
   private static final String CLIENT_NAME_KEY = "clientName";
   private static final String CLIENT_NAME_TRANSLATIONS_KEY = "clientNameTranslations";
   private static final String CLIENT_ID_ISSUED_AT_KEY = "clientIdIssuedAt";
   private static final String REDIRECT_URIS_KEY = "redirectUris";
   private static final String TOKEN_ENDPOINT_AUTH_METHOD_KEY = "tokenEndpointAuthMethod";
   private static final String GRANT_TYPES_KEY = "grantTypes";
   private static final String RESPONSE_TYPES_KEY = "responseTypes";
   private static final String CLIENT_URI_KEY = "clientUri";
   private static final String CLIENT_URI_TRANSLATIONS_KEY = "clientUriTranslations";
   private static final String LOGO_URI_KEY = "logoUri";
   private static final String LOGO_URI_TRANSLATIONS_KEY = "logoUriTranslations";
   private static final String SCOPES_KEY = "scopes";
   private static final String CONTACTS_KEY = "contacts";
   private static final String TOS_URI_KEY = "tosUri";
   private static final String TOS_URI_TRANSLATIONS_KEY = "tosUriTranslations";
   private static final String POLICY_URI_KEY = "policyUri";
   private static final String POLICY_URI_TRANSLATIONS_KEY = "policyUriTranslations";
   private static final String SOFTWARE_ID_KEY = "softwareId";
   private static final String SOFTWARE_VERSION_KEY = "softwareVersion";
   @NonNull
   private final Optional<Identity<TechnicalClient>> techClientId;
   @NonNull
   private final OAuth2ClientId clientId;
   @NonNull
   private final Optional<OAuth2ClientSecret> clientSecret;
   @NonNull
   private final Optional<String> clientName;
   @NonNull
   private final Map<Locale, String> clientNameTranslations;
   @NonNull
   private final Optional<Instant> clientIdIssuedAt;
   @NonNull
   private final Set<URI> redirectUris;
   @NonNull
   private final Optional<String> tokenEndpointAuthMethod;
   @NonNull
   private final List<String> grantTypes;
   @NonNull
   private final List<String> responseTypes;
   @NonNull
   private final Optional<URI> clientUri;
   @NonNull
   private final Map<Locale, URI> clientUriTranslations;
   @NonNull
   private final Optional<URI> logoUri;
   @NonNull
   private final Map<Locale, URI> logoUriTranslations;
   @NonNull
   private final List<OAuth2Scope> scopes;
   @NonNull
   private final List<String> contacts;
   @NonNull
   private final Optional<URI> tosUri;
   @NonNull
   private final Map<Locale, URI> tosUriTranslations;
   @NonNull
   private final Optional<URI> policyUri;
   @NonNull
   private final Map<Locale, URI> policyUriTranslations;
   @NonNull
   private final Optional<String> softwareId;
   @NonNull
   private final Optional<String> softwareVersion;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues()
         .put("clientId", this.clientId.id())
         .putIfPresent("techClientId", this.techClientId.map(OAuth2ClientRegistrationResponseData.TechClientIdentityMapifier::mapify))
         .putIfPresent("clientSecret", this.clientSecret.map(OAuth2ClientRegistrationResponseData.OAuth2ClientSecretMapifier::mapify))
         .putIfPresent("clientName", this.clientName)
         .put("clientNameTranslations", this.mapifyLocaleToStringMap(this.clientNameTranslations))
         .putIfPresent("clientIdIssuedAt", this.clientIdIssuedAt.map(MapificationUtils::mapifyInstant))
         .putIfNotEmpty("redirectUris", MapificationUtils.mapifyCollection(this.redirectUris, URI::toString))
         .putIfPresent("tokenEndpointAuthMethod", this.tokenEndpointAuthMethod)
         .putIfNotEmpty("grantTypes", this.grantTypes)
         .putIfNotEmpty("responseTypes", this.responseTypes)
         .putIfPresent("clientUri", this.clientUri.map(URI::toString))
         .put("clientUriTranslations", this.mapifyLocaleToUriMap(this.clientUriTranslations))
         .putIfPresent("logoUri", this.logoUri.map(URI::toString))
         .put("logoUriTranslations", this.mapifyLocaleToUriMap(this.logoUriTranslations))
         .putIfNotEmpty("scopes", OAuth2Scope.convertToScopeNamesList(this.scopes))
         .putIfNotEmpty("contacts", this.contacts)
         .putIfPresent("tosUri", this.tosUri.map(URI::toString))
         .put("tosUriTranslations", this.mapifyLocaleToUriMap(this.tosUriTranslations))
         .putIfPresent("policyUri", this.policyUri.map(URI::toString))
         .put("policyUriTranslations", this.mapifyLocaleToUriMap(this.policyUriTranslations))
         .putIfPresent("softwareId", this.softwareId)
         .putIfPresent("softwareVersion", this.softwareVersion)
         .build();
   }

   public static OAuth2ClientRegistrationResponseData demapify(MapifiedValues values) {
      return new OAuth2ClientRegistrationResponseData(
         values.demapifyOptional("techClientId", OAuth2ClientRegistrationResponseData.TechClientIdentityMapifier::demapify),
         OAuth2ClientId.oAuth2ClientId(values.get("clientId")),
         values.demapifyOptional("clientSecret", OAuth2ClientRegistrationResponseData.OAuth2ClientSecretMapifier::demapify),
         values.getOptional("clientName"),
         demapifyLocaleToStringMap(values.getValues("clientNameTranslations")),
         values.demapifyOptional("clientIdIssuedAt", MapificationUtils::demapifyInstant),
         values.<String>getList("redirectUris").stream().map(URI::create).collect(Collectors.toSet()),
         values.getOptional("tokenEndpointAuthMethod"),
         values.getList("grantTypes"),
         values.getList("responseTypes"),
         values.<String>getOptional("clientUri").map(URI::create),
         demapifyLocaleToUriMap(values.getValues("clientUriTranslations")),
         values.<String>getOptional("logoUri").map(URI::create),
         demapifyLocaleToUriMap(values.getValues("logoUriTranslations")),
         values.<String>getList("scopes").stream().map(OAuth2Scope::of).toList(),
         values.getList("contacts"),
         values.<String>getOptional("tosUri").map(URI::create),
         demapifyLocaleToUriMap(values.getValues("tosUriTranslations")),
         values.<String>getOptional("policyUri").map(URI::create),
         demapifyLocaleToUriMap(values.getValues("policyUriTranslations")),
         values.getOptional("softwareId"),
         values.getOptional("softwareVersion")
      );
   }

   private static Map<Locale, String> demapifyLocaleToStringMap(MapifiedValues values) {
      HashMap<Locale, String> result = new HashMap<>();

      for (Entry<String, Object> entry : values.asMap().entrySet()) {
         result.put(LocaleUtils.toLocale(entry.getKey()), (String)entry.getValue());
      }

      return result;
   }

   private static Map<Locale, URI> demapifyLocaleToUriMap(MapifiedValues values) {
      HashMap<Locale, URI> result = new HashMap<>();

      for (Entry<String, Object> entry : values.asMap().entrySet()) {
         result.put(LocaleUtils.toLocale(entry.getKey()), URI.create((String)entry.getValue()));
      }

      return result;
   }

   private MapifiedValues mapifyLocaleToStringMap(Map<Locale, String> localeStringMap) {
      MapifiedValuesBuilder result = MapifiedValuesBuilder.mapifiedValues();

      for (Entry<Locale, String> entry : localeStringMap.entrySet()) {
         result.put(entry.getKey().toString(), entry.getValue());
      }

      return result.build();
   }

   private MapifiedValues mapifyLocaleToUriMap(Map<Locale, URI> localeStringMap) {
      MapifiedValuesBuilder result = MapifiedValuesBuilder.mapifiedValues();

      for (Entry<Locale, URI> entry : localeStringMap.entrySet()) {
         result.put(entry.getKey().toString(), entry.getValue().toString());
      }

      return result.build();
   }

   @SuppressFBWarnings(justification = "generated code")
   OAuth2ClientRegistrationResponseData(
      @NonNull Optional<Identity<TechnicalClient>> techClientId,
      @NonNull OAuth2ClientId clientId,
      @NonNull Optional<OAuth2ClientSecret> clientSecret,
      @NonNull Optional<String> clientName,
      @NonNull Map<Locale, String> clientNameTranslations,
      @NonNull Optional<Instant> clientIdIssuedAt,
      @NonNull Set<URI> redirectUris,
      @NonNull Optional<String> tokenEndpointAuthMethod,
      @NonNull List<String> grantTypes,
      @NonNull List<String> responseTypes,
      @NonNull Optional<URI> clientUri,
      @NonNull Map<Locale, URI> clientUriTranslations,
      @NonNull Optional<URI> logoUri,
      @NonNull Map<Locale, URI> logoUriTranslations,
      @NonNull List<OAuth2Scope> scopes,
      @NonNull List<String> contacts,
      @NonNull Optional<URI> tosUri,
      @NonNull Map<Locale, URI> tosUriTranslations,
      @NonNull Optional<URI> policyUri,
      @NonNull Map<Locale, URI> policyUriTranslations,
      @NonNull Optional<String> softwareId,
      @NonNull Optional<String> softwareVersion
   ) {
      if (techClientId == null) {
         throw new NullPointerException("techClientId is marked non-null but is null");
      }

      if (clientId == null) {
         throw new NullPointerException("clientId is marked non-null but is null");
      }

      if (clientSecret == null) {
         throw new NullPointerException("clientSecret is marked non-null but is null");
      }

      if (clientName == null) {
         throw new NullPointerException("clientName is marked non-null but is null");
      }

      if (clientNameTranslations == null) {
         throw new NullPointerException("clientNameTranslations is marked non-null but is null");
      }

      if (clientIdIssuedAt == null) {
         throw new NullPointerException("clientIdIssuedAt is marked non-null but is null");
      }

      if (redirectUris == null) {
         throw new NullPointerException("redirectUris is marked non-null but is null");
      }

      if (tokenEndpointAuthMethod == null) {
         throw new NullPointerException("tokenEndpointAuthMethod is marked non-null but is null");
      }

      if (grantTypes == null) {
         throw new NullPointerException("grantTypes is marked non-null but is null");
      }

      if (responseTypes == null) {
         throw new NullPointerException("responseTypes is marked non-null but is null");
      }

      if (clientUri == null) {
         throw new NullPointerException("clientUri is marked non-null but is null");
      }

      if (clientUriTranslations == null) {
         throw new NullPointerException("clientUriTranslations is marked non-null but is null");
      }

      if (logoUri == null) {
         throw new NullPointerException("logoUri is marked non-null but is null");
      }

      if (logoUriTranslations == null) {
         throw new NullPointerException("logoUriTranslations is marked non-null but is null");
      }

      if (scopes == null) {
         throw new NullPointerException("scopes is marked non-null but is null");
      }

      if (contacts == null) {
         throw new NullPointerException("contacts is marked non-null but is null");
      }

      if (tosUri == null) {
         throw new NullPointerException("tosUri is marked non-null but is null");
      }

      if (tosUriTranslations == null) {
         throw new NullPointerException("tosUriTranslations is marked non-null but is null");
      }

      if (policyUri == null) {
         throw new NullPointerException("policyUri is marked non-null but is null");
      }

      if (policyUriTranslations == null) {
         throw new NullPointerException("policyUriTranslations is marked non-null but is null");
      }

      if (softwareId == null) {
         throw new NullPointerException("softwareId is marked non-null but is null");
      }

      if (softwareVersion == null) {
         throw new NullPointerException("softwareVersion is marked non-null but is null");
      }

      this.techClientId = techClientId;
      this.clientId = clientId;
      this.clientSecret = clientSecret;
      this.clientName = clientName;
      this.clientNameTranslations = clientNameTranslations;
      this.clientIdIssuedAt = clientIdIssuedAt;
      this.redirectUris = redirectUris;
      this.tokenEndpointAuthMethod = tokenEndpointAuthMethod;
      this.grantTypes = grantTypes;
      this.responseTypes = responseTypes;
      this.clientUri = clientUri;
      this.clientUriTranslations = clientUriTranslations;
      this.logoUri = logoUri;
      this.logoUriTranslations = logoUriTranslations;
      this.scopes = scopes;
      this.contacts = contacts;
      this.tosUri = tosUri;
      this.tosUriTranslations = tosUriTranslations;
      this.policyUri = policyUri;
      this.policyUriTranslations = policyUriTranslations;
      this.softwareId = softwareId;
      this.softwareVersion = softwareVersion;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder builder() {
      return new OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder();
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<Identity<TechnicalClient>> getTechClientId() {
      return this.techClientId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ClientId getClientId() {
      return this.clientId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<OAuth2ClientSecret> getClientSecret() {
      return this.clientSecret;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getClientName() {
      return this.clientName;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<Locale, String> getClientNameTranslations() {
      return this.clientNameTranslations;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<Instant> getClientIdIssuedAt() {
      return this.clientIdIssuedAt;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Set<URI> getRedirectUris() {
      return this.redirectUris;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getTokenEndpointAuthMethod() {
      return this.tokenEndpointAuthMethod;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<String> getGrantTypes() {
      return this.grantTypes;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<String> getResponseTypes() {
      return this.responseTypes;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<URI> getClientUri() {
      return this.clientUri;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<Locale, URI> getClientUriTranslations() {
      return this.clientUriTranslations;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<URI> getLogoUri() {
      return this.logoUri;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<Locale, URI> getLogoUriTranslations() {
      return this.logoUriTranslations;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<OAuth2Scope> getScopes() {
      return this.scopes;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<String> getContacts() {
      return this.contacts;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<URI> getTosUri() {
      return this.tosUri;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<Locale, URI> getTosUriTranslations() {
      return this.tosUriTranslations;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<URI> getPolicyUri() {
      return this.policyUri;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<Locale, URI> getPolicyUriTranslations() {
      return this.policyUriTranslations;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getSoftwareId() {
      return this.softwareId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getSoftwareVersion() {
      return this.softwareVersion;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof OAuth2ClientRegistrationResponseData other)) {
         return false;
      } else {
         Object this$techClientId = this.techClientId;
         Object other$techClientId = other.techClientId;
         if (this$techClientId == null ? other$techClientId == null : this$techClientId.equals(other$techClientId)) {
            Object this$clientId = this.clientId;
            Object other$clientId = other.clientId;
            if (this$clientId == null ? other$clientId == null : this$clientId.equals(other$clientId)) {
               Object this$clientSecret = this.clientSecret;
               Object other$clientSecret = other.clientSecret;
               if (this$clientSecret == null ? other$clientSecret == null : this$clientSecret.equals(other$clientSecret)) {
                  Object this$clientName = this.clientName;
                  Object other$clientName = other.clientName;
                  if (this$clientName == null ? other$clientName == null : this$clientName.equals(other$clientName)) {
                     Object this$clientNameTranslations = this.clientNameTranslations;
                     Object other$clientNameTranslations = other.clientNameTranslations;
                     if (this$clientNameTranslations == null
                        ? other$clientNameTranslations == null
                        : this$clientNameTranslations.equals(other$clientNameTranslations)) {
                        Object this$clientIdIssuedAt = this.clientIdIssuedAt;
                        Object other$clientIdIssuedAt = other.clientIdIssuedAt;
                        if (this$clientIdIssuedAt == null ? other$clientIdIssuedAt == null : this$clientIdIssuedAt.equals(other$clientIdIssuedAt)) {
                           Object this$redirectUris = this.redirectUris;
                           Object other$redirectUris = other.redirectUris;
                           if (this$redirectUris == null ? other$redirectUris == null : this$redirectUris.equals(other$redirectUris)) {
                              Object this$tokenEndpointAuthMethod = this.tokenEndpointAuthMethod;
                              Object other$tokenEndpointAuthMethod = other.tokenEndpointAuthMethod;
                              if (this$tokenEndpointAuthMethod == null
                                 ? other$tokenEndpointAuthMethod == null
                                 : this$tokenEndpointAuthMethod.equals(other$tokenEndpointAuthMethod)) {
                                 Object this$grantTypes = this.grantTypes;
                                 Object other$grantTypes = other.grantTypes;
                                 if (this$grantTypes == null ? other$grantTypes == null : this$grantTypes.equals(other$grantTypes)) {
                                    Object this$responseTypes = this.responseTypes;
                                    Object other$responseTypes = other.responseTypes;
                                    if (this$responseTypes == null ? other$responseTypes == null : this$responseTypes.equals(other$responseTypes)) {
                                       Object this$clientUri = this.clientUri;
                                       Object other$clientUri = other.clientUri;
                                       if (this$clientUri == null ? other$clientUri == null : this$clientUri.equals(other$clientUri)) {
                                          Object this$clientUriTranslations = this.clientUriTranslations;
                                          Object other$clientUriTranslations = other.clientUriTranslations;
                                          if (this$clientUriTranslations == null
                                             ? other$clientUriTranslations == null
                                             : this$clientUriTranslations.equals(other$clientUriTranslations)) {
                                             Object this$logoUri = this.logoUri;
                                             Object other$logoUri = other.logoUri;
                                             if (this$logoUri == null ? other$logoUri == null : this$logoUri.equals(other$logoUri)) {
                                                Object this$logoUriTranslations = this.logoUriTranslations;
                                                Object other$logoUriTranslations = other.logoUriTranslations;
                                                if (this$logoUriTranslations == null
                                                   ? other$logoUriTranslations == null
                                                   : this$logoUriTranslations.equals(other$logoUriTranslations)) {
                                                   Object this$scopes = this.scopes;
                                                   Object other$scopes = other.scopes;
                                                   if (this$scopes == null ? other$scopes == null : this$scopes.equals(other$scopes)) {
                                                      Object this$contacts = this.contacts;
                                                      Object other$contacts = other.contacts;
                                                      if (this$contacts == null ? other$contacts == null : this$contacts.equals(other$contacts)) {
                                                         Object this$tosUri = this.tosUri;
                                                         Object other$tosUri = other.tosUri;
                                                         if (this$tosUri == null ? other$tosUri == null : this$tosUri.equals(other$tosUri)) {
                                                            Object this$tosUriTranslations = this.tosUriTranslations;
                                                            Object other$tosUriTranslations = other.tosUriTranslations;
                                                            if (this$tosUriTranslations == null
                                                               ? other$tosUriTranslations == null
                                                               : this$tosUriTranslations.equals(other$tosUriTranslations)) {
                                                               Object this$policyUri = this.policyUri;
                                                               Object other$policyUri = other.policyUri;
                                                               if (this$policyUri == null ? other$policyUri == null : this$policyUri.equals(other$policyUri)) {
                                                                  Object this$policyUriTranslations = this.policyUriTranslations;
                                                                  Object other$policyUriTranslations = other.policyUriTranslations;
                                                                  if (this$policyUriTranslations == null
                                                                     ? other$policyUriTranslations == null
                                                                     : this$policyUriTranslations.equals(other$policyUriTranslations)) {
                                                                     Object this$softwareId = this.softwareId;
                                                                     Object other$softwareId = other.softwareId;
                                                                     if (this$softwareId == null
                                                                        ? other$softwareId == null
                                                                        : this$softwareId.equals(other$softwareId)) {
                                                                        Object this$softwareVersion = this.softwareVersion;
                                                                        Object other$softwareVersion = other.softwareVersion;
                                                                        return this$softwareVersion == null
                                                                           ? other$softwareVersion == null
                                                                           : this$softwareVersion.equals(other$softwareVersion);
                                                                     } else {
                                                                        return false;
                                                                     }
                                                                  } else {
                                                                     return false;
                                                                  }
                                                               } else {
                                                                  return false;
                                                               }
                                                            } else {
                                                               return false;
                                                            }
                                                         } else {
                                                            return false;
                                                         }
                                                      } else {
                                                         return false;
                                                      }
                                                   } else {
                                                      return false;
                                                   }
                                                } else {
                                                   return false;
                                                }
                                             } else {
                                                return false;
                                             }
                                          } else {
                                             return false;
                                          }
                                       } else {
                                          return false;
                                       }
                                    } else {
                                       return false;
                                    }
                                 } else {
                                    return false;
                                 }
                              } else {
                                 return false;
                              }
                           } else {
                              return false;
                           }
                        } else {
                           return false;
                        }
                     } else {
                        return false;
                     }
                  } else {
                     return false;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      Object $techClientId = this.techClientId;
      result = result * 59 + ($techClientId == null ? 43 : $techClientId.hashCode());
      Object $clientId = this.clientId;
      result = result * 59 + ($clientId == null ? 43 : $clientId.hashCode());
      Object $clientSecret = this.clientSecret;
      result = result * 59 + ($clientSecret == null ? 43 : $clientSecret.hashCode());
      Object $clientName = this.clientName;
      result = result * 59 + ($clientName == null ? 43 : $clientName.hashCode());
      Object $clientNameTranslations = this.clientNameTranslations;
      result = result * 59 + ($clientNameTranslations == null ? 43 : $clientNameTranslations.hashCode());
      Object $clientIdIssuedAt = this.clientIdIssuedAt;
      result = result * 59 + ($clientIdIssuedAt == null ? 43 : $clientIdIssuedAt.hashCode());
      Object $redirectUris = this.redirectUris;
      result = result * 59 + ($redirectUris == null ? 43 : $redirectUris.hashCode());
      Object $tokenEndpointAuthMethod = this.tokenEndpointAuthMethod;
      result = result * 59 + ($tokenEndpointAuthMethod == null ? 43 : $tokenEndpointAuthMethod.hashCode());
      Object $grantTypes = this.grantTypes;
      result = result * 59 + ($grantTypes == null ? 43 : $grantTypes.hashCode());
      Object $responseTypes = this.responseTypes;
      result = result * 59 + ($responseTypes == null ? 43 : $responseTypes.hashCode());
      Object $clientUri = this.clientUri;
      result = result * 59 + ($clientUri == null ? 43 : $clientUri.hashCode());
      Object $clientUriTranslations = this.clientUriTranslations;
      result = result * 59 + ($clientUriTranslations == null ? 43 : $clientUriTranslations.hashCode());
      Object $logoUri = this.logoUri;
      result = result * 59 + ($logoUri == null ? 43 : $logoUri.hashCode());
      Object $logoUriTranslations = this.logoUriTranslations;
      result = result * 59 + ($logoUriTranslations == null ? 43 : $logoUriTranslations.hashCode());
      Object $scopes = this.scopes;
      result = result * 59 + ($scopes == null ? 43 : $scopes.hashCode());
      Object $contacts = this.contacts;
      result = result * 59 + ($contacts == null ? 43 : $contacts.hashCode());
      Object $tosUri = this.tosUri;
      result = result * 59 + ($tosUri == null ? 43 : $tosUri.hashCode());
      Object $tosUriTranslations = this.tosUriTranslations;
      result = result * 59 + ($tosUriTranslations == null ? 43 : $tosUriTranslations.hashCode());
      Object $policyUri = this.policyUri;
      result = result * 59 + ($policyUri == null ? 43 : $policyUri.hashCode());
      Object $policyUriTranslations = this.policyUriTranslations;
      result = result * 59 + ($policyUriTranslations == null ? 43 : $policyUriTranslations.hashCode());
      Object $softwareId = this.softwareId;
      result = result * 59 + ($softwareId == null ? 43 : $softwareId.hashCode());
      Object $softwareVersion = this.softwareVersion;
      return result * 59 + ($softwareVersion == null ? 43 : $softwareVersion.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2ClientRegistrationResponseData(techClientId="
         + this.getTechClientId()
         + ", clientId="
         + this.getClientId()
         + ", clientSecret="
         + this.getClientSecret()
         + ", clientName="
         + this.getClientName()
         + ", clientNameTranslations="
         + this.getClientNameTranslations()
         + ", clientIdIssuedAt="
         + this.getClientIdIssuedAt()
         + ", redirectUris="
         + this.getRedirectUris()
         + ", tokenEndpointAuthMethod="
         + this.getTokenEndpointAuthMethod()
         + ", grantTypes="
         + this.getGrantTypes()
         + ", responseTypes="
         + this.getResponseTypes()
         + ", clientUri="
         + this.getClientUri()
         + ", clientUriTranslations="
         + this.getClientUriTranslations()
         + ", logoUri="
         + this.getLogoUri()
         + ", logoUriTranslations="
         + this.getLogoUriTranslations()
         + ", scopes="
         + this.getScopes()
         + ", contacts="
         + this.getContacts()
         + ", tosUri="
         + this.getTosUri()
         + ", tosUriTranslations="
         + this.getTosUriTranslations()
         + ", policyUri="
         + this.getPolicyUri()
         + ", policyUriTranslations="
         + this.getPolicyUriTranslations()
         + ", softwareId="
         + this.getSoftwareId()
         + ", softwareVersion="
         + this.getSoftwareVersion()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2ClientRegistrationResponseDataBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Identity<TechnicalClient>> techClientId;
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2ClientId clientId;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<OAuth2ClientSecret> clientSecret;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> clientName;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Locale> clientNameTranslations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<String> clientNameTranslations$value;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Instant> clientIdIssuedAt;
      @SuppressFBWarnings(justification = "generated code")
      private Set<URI> redirectUris;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> tokenEndpointAuthMethod;
      @SuppressFBWarnings(justification = "generated code")
      private List<String> grantTypes;
      @SuppressFBWarnings(justification = "generated code")
      private List<String> responseTypes;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<URI> clientUri;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Locale> clientUriTranslations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<URI> clientUriTranslations$value;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<URI> logoUri;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Locale> logoUriTranslations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<URI> logoUriTranslations$value;
      @SuppressFBWarnings(justification = "generated code")
      private List<OAuth2Scope> scopes;
      @SuppressFBWarnings(justification = "generated code")
      private List<String> contacts;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<URI> tosUri;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Locale> tosUriTranslations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<URI> tosUriTranslations$value;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<URI> policyUri;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Locale> policyUriTranslations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<URI> policyUriTranslations$value;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> softwareId;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> softwareVersion;

      @SuppressFBWarnings(justification = "generated code")
      OAuth2ClientRegistrationResponseDataBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder techClientId(
         @NonNull Optional<Identity<TechnicalClient>> techClientId
      ) {
         if (techClientId == null) {
            throw new NullPointerException("techClientId is marked non-null but is null");
         }

         this.techClientId = techClientId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientId(@NonNull OAuth2ClientId clientId) {
         if (clientId == null) {
            throw new NullPointerException("clientId is marked non-null but is null");
         }

         this.clientId = clientId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientSecret(@NonNull Optional<OAuth2ClientSecret> clientSecret) {
         if (clientSecret == null) {
            throw new NullPointerException("clientSecret is marked non-null but is null");
         }

         this.clientSecret = clientSecret;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientName(@NonNull Optional<String> clientName) {
         if (clientName == null) {
            throw new NullPointerException("clientName is marked non-null but is null");
         }

         this.clientName = clientName;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientNameTranslation(
         Locale clientNameTranslationKey, String clientNameTranslationValue
      ) {
         if (this.clientNameTranslations$key == null) {
            this.clientNameTranslations$key = new ArrayList<>();
            this.clientNameTranslations$value = new ArrayList<>();
         }

         this.clientNameTranslations$key.add(clientNameTranslationKey);
         this.clientNameTranslations$value.add(clientNameTranslationValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientNameTranslations(
         Map<? extends Locale, ? extends String> clientNameTranslations
      ) {
         if (clientNameTranslations == null) {
            throw new NullPointerException("clientNameTranslations cannot be null");
         }

         if (this.clientNameTranslations$key == null) {
            this.clientNameTranslations$key = new ArrayList<>();
            this.clientNameTranslations$value = new ArrayList<>();
         }

         for (Entry<? extends Locale, ? extends String> $lombokEntry : clientNameTranslations.entrySet()) {
            this.clientNameTranslations$key.add($lombokEntry.getKey());
            this.clientNameTranslations$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clearClientNameTranslations() {
         if (this.clientNameTranslations$key != null) {
            this.clientNameTranslations$key.clear();
            this.clientNameTranslations$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientIdIssuedAt(@NonNull Optional<Instant> clientIdIssuedAt) {
         if (clientIdIssuedAt == null) {
            throw new NullPointerException("clientIdIssuedAt is marked non-null but is null");
         }

         this.clientIdIssuedAt = clientIdIssuedAt;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder redirectUris(@NonNull Set<URI> redirectUris) {
         if (redirectUris == null) {
            throw new NullPointerException("redirectUris is marked non-null but is null");
         }

         this.redirectUris = redirectUris;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder tokenEndpointAuthMethod(
         @NonNull Optional<String> tokenEndpointAuthMethod
      ) {
         if (tokenEndpointAuthMethod == null) {
            throw new NullPointerException("tokenEndpointAuthMethod is marked non-null but is null");
         }

         this.tokenEndpointAuthMethod = tokenEndpointAuthMethod;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder grantTypes(@NonNull List<String> grantTypes) {
         if (grantTypes == null) {
            throw new NullPointerException("grantTypes is marked non-null but is null");
         }

         this.grantTypes = grantTypes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder responseTypes(@NonNull List<String> responseTypes) {
         if (responseTypes == null) {
            throw new NullPointerException("responseTypes is marked non-null but is null");
         }

         this.responseTypes = responseTypes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientUri(@NonNull Optional<URI> clientUri) {
         if (clientUri == null) {
            throw new NullPointerException("clientUri is marked non-null but is null");
         }

         this.clientUri = clientUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientUriTranslation(
         Locale clientUriTranslationKey, URI clientUriTranslationValue
      ) {
         if (this.clientUriTranslations$key == null) {
            this.clientUriTranslations$key = new ArrayList<>();
            this.clientUriTranslations$value = new ArrayList<>();
         }

         this.clientUriTranslations$key.add(clientUriTranslationKey);
         this.clientUriTranslations$value.add(clientUriTranslationValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clientUriTranslations(
         Map<? extends Locale, ? extends URI> clientUriTranslations
      ) {
         if (clientUriTranslations == null) {
            throw new NullPointerException("clientUriTranslations cannot be null");
         }

         if (this.clientUriTranslations$key == null) {
            this.clientUriTranslations$key = new ArrayList<>();
            this.clientUriTranslations$value = new ArrayList<>();
         }

         for (Entry<? extends Locale, ? extends URI> $lombokEntry : clientUriTranslations.entrySet()) {
            this.clientUriTranslations$key.add($lombokEntry.getKey());
            this.clientUriTranslations$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clearClientUriTranslations() {
         if (this.clientUriTranslations$key != null) {
            this.clientUriTranslations$key.clear();
            this.clientUriTranslations$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder logoUri(@NonNull Optional<URI> logoUri) {
         if (logoUri == null) {
            throw new NullPointerException("logoUri is marked non-null but is null");
         }

         this.logoUri = logoUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder logoUriTranslation(
         Locale logoUriTranslationKey, URI logoUriTranslationValue
      ) {
         if (this.logoUriTranslations$key == null) {
            this.logoUriTranslations$key = new ArrayList<>();
            this.logoUriTranslations$value = new ArrayList<>();
         }

         this.logoUriTranslations$key.add(logoUriTranslationKey);
         this.logoUriTranslations$value.add(logoUriTranslationValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder logoUriTranslations(
         Map<? extends Locale, ? extends URI> logoUriTranslations
      ) {
         if (logoUriTranslations == null) {
            throw new NullPointerException("logoUriTranslations cannot be null");
         }

         if (this.logoUriTranslations$key == null) {
            this.logoUriTranslations$key = new ArrayList<>();
            this.logoUriTranslations$value = new ArrayList<>();
         }

         for (Entry<? extends Locale, ? extends URI> $lombokEntry : logoUriTranslations.entrySet()) {
            this.logoUriTranslations$key.add($lombokEntry.getKey());
            this.logoUriTranslations$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clearLogoUriTranslations() {
         if (this.logoUriTranslations$key != null) {
            this.logoUriTranslations$key.clear();
            this.logoUriTranslations$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder scopes(@NonNull List<OAuth2Scope> scopes) {
         if (scopes == null) {
            throw new NullPointerException("scopes is marked non-null but is null");
         }

         this.scopes = scopes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder contacts(@NonNull List<String> contacts) {
         if (contacts == null) {
            throw new NullPointerException("contacts is marked non-null but is null");
         }

         this.contacts = contacts;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder tosUri(@NonNull Optional<URI> tosUri) {
         if (tosUri == null) {
            throw new NullPointerException("tosUri is marked non-null but is null");
         }

         this.tosUri = tosUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder tosUriTranslation(
         Locale tosUriTranslationKey, URI tosUriTranslationValue
      ) {
         if (this.tosUriTranslations$key == null) {
            this.tosUriTranslations$key = new ArrayList<>();
            this.tosUriTranslations$value = new ArrayList<>();
         }

         this.tosUriTranslations$key.add(tosUriTranslationKey);
         this.tosUriTranslations$value.add(tosUriTranslationValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder tosUriTranslations(
         Map<? extends Locale, ? extends URI> tosUriTranslations
      ) {
         if (tosUriTranslations == null) {
            throw new NullPointerException("tosUriTranslations cannot be null");
         }

         if (this.tosUriTranslations$key == null) {
            this.tosUriTranslations$key = new ArrayList<>();
            this.tosUriTranslations$value = new ArrayList<>();
         }

         for (Entry<? extends Locale, ? extends URI> $lombokEntry : tosUriTranslations.entrySet()) {
            this.tosUriTranslations$key.add($lombokEntry.getKey());
            this.tosUriTranslations$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clearTosUriTranslations() {
         if (this.tosUriTranslations$key != null) {
            this.tosUriTranslations$key.clear();
            this.tosUriTranslations$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder policyUri(@NonNull Optional<URI> policyUri) {
         if (policyUri == null) {
            throw new NullPointerException("policyUri is marked non-null but is null");
         }

         this.policyUri = policyUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder policyUriTranslation(
         Locale policyUriTranslationKey, URI policyUriTranslationValue
      ) {
         if (this.policyUriTranslations$key == null) {
            this.policyUriTranslations$key = new ArrayList<>();
            this.policyUriTranslations$value = new ArrayList<>();
         }

         this.policyUriTranslations$key.add(policyUriTranslationKey);
         this.policyUriTranslations$value.add(policyUriTranslationValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder policyUriTranslations(
         Map<? extends Locale, ? extends URI> policyUriTranslations
      ) {
         if (policyUriTranslations == null) {
            throw new NullPointerException("policyUriTranslations cannot be null");
         }

         if (this.policyUriTranslations$key == null) {
            this.policyUriTranslations$key = new ArrayList<>();
            this.policyUriTranslations$value = new ArrayList<>();
         }

         for (Entry<? extends Locale, ? extends URI> $lombokEntry : policyUriTranslations.entrySet()) {
            this.policyUriTranslations$key.add($lombokEntry.getKey());
            this.policyUriTranslations$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder clearPolicyUriTranslations() {
         if (this.policyUriTranslations$key != null) {
            this.policyUriTranslations$key.clear();
            this.policyUriTranslations$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder softwareId(@NonNull Optional<String> softwareId) {
         if (softwareId == null) {
            throw new NullPointerException("softwareId is marked non-null but is null");
         }

         this.softwareId = softwareId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder softwareVersion(@NonNull Optional<String> softwareVersion) {
         if (softwareVersion == null) {
            throw new NullPointerException("softwareVersion is marked non-null but is null");
         }

         this.softwareVersion = softwareVersion;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientRegistrationResponseData build() {
         Map var7 = switch (this.clientNameTranslations$key == null ? 0 : this.clientNameTranslations$key.size()) {
            case 0 -> Collections.emptyMap();
            case 1 -> Collections.singletonMap(this.clientNameTranslations$key.get(0), this.clientNameTranslations$value.get(0));
            default -> {
               Map<Locale, String> clientNameTranslations = new LinkedHashMap<>(
                  this.clientNameTranslations$key.size() < 1073741824
                     ? 1 + this.clientNameTranslations$key.size() + (this.clientNameTranslations$key.size() - 3) / 3
                     : Integer.MAX_VALUE
               );

               for (int $i = 0; $i < this.clientNameTranslations$key.size(); $i++) {
                  clientNameTranslations.put(this.clientNameTranslations$key.get($i), this.clientNameTranslations$value.get($i));
               }

               yield Collections.unmodifiableMap(clientNameTranslations);
            }
         };

         Map var9 = switch (this.clientUriTranslations$key == null ? 0 : this.clientUriTranslations$key.size()) {
            case 0 -> Collections.emptyMap();
            case 1 -> Collections.singletonMap(this.clientUriTranslations$key.get(0), this.clientUriTranslations$value.get(0));
            default -> {
               Map<Locale, URI> clientUriTranslations = new LinkedHashMap<>(
                  this.clientUriTranslations$key.size() < 1073741824
                     ? 1 + this.clientUriTranslations$key.size() + (this.clientUriTranslations$key.size() - 3) / 3
                     : Integer.MAX_VALUE
               );

               for (int $i = 0; $i < this.clientUriTranslations$key.size(); $i++) {
                  clientUriTranslations.put(this.clientUriTranslations$key.get($i), this.clientUriTranslations$value.get($i));
               }

               yield Collections.unmodifiableMap(clientUriTranslations);
            }
         };

         Map var11 = switch (this.logoUriTranslations$key == null ? 0 : this.logoUriTranslations$key.size()) {
            case 0 -> Collections.emptyMap();
            case 1 -> Collections.singletonMap(this.logoUriTranslations$key.get(0), this.logoUriTranslations$value.get(0));
            default -> {
               Map<Locale, URI> logoUriTranslations = new LinkedHashMap<>(
                  this.logoUriTranslations$key.size() < 1073741824
                     ? 1 + this.logoUriTranslations$key.size() + (this.logoUriTranslations$key.size() - 3) / 3
                     : Integer.MAX_VALUE
               );

               for (int $i = 0; $i < this.logoUriTranslations$key.size(); $i++) {
                  logoUriTranslations.put(this.logoUriTranslations$key.get($i), this.logoUriTranslations$value.get($i));
               }

               yield Collections.unmodifiableMap(logoUriTranslations);
            }
         };

         Map var13 = switch (this.tosUriTranslations$key == null ? 0 : this.tosUriTranslations$key.size()) {
            case 0 -> Collections.emptyMap();
            case 1 -> Collections.singletonMap(this.tosUriTranslations$key.get(0), this.tosUriTranslations$value.get(0));
            default -> {
               Map<Locale, URI> tosUriTranslations = new LinkedHashMap<>(
                  this.tosUriTranslations$key.size() < 1073741824
                     ? 1 + this.tosUriTranslations$key.size() + (this.tosUriTranslations$key.size() - 3) / 3
                     : Integer.MAX_VALUE
               );

               for (int $i = 0; $i < this.tosUriTranslations$key.size(); $i++) {
                  tosUriTranslations.put(this.tosUriTranslations$key.get($i), this.tosUriTranslations$value.get($i));
               }

               yield Collections.unmodifiableMap(tosUriTranslations);
            }
         };

         return new OAuth2ClientRegistrationResponseData(
            this.techClientId,
            this.clientId,
            this.clientSecret,
            this.clientName,
            var7,
            this.clientIdIssuedAt,
            this.redirectUris,
            this.tokenEndpointAuthMethod,
            this.grantTypes,
            this.responseTypes,
            this.clientUri,
            var9,
            this.logoUri,
            var11,
            this.scopes,
            this.contacts,
            this.tosUri,
            var13,
            this.policyUri,
            switch (this.policyUriTranslations$key == null ? 0 : this.policyUriTranslations$key.size()) {
               case 0 -> Collections.emptyMap();
               case 1 -> Collections.singletonMap(this.policyUriTranslations$key.get(0), this.policyUriTranslations$value.get(0));
               default -> {
                  Map<Locale, URI> policyUriTranslations = new LinkedHashMap<>(
                     this.policyUriTranslations$key.size() < 1073741824
                        ? 1 + this.policyUriTranslations$key.size() + (this.policyUriTranslations$key.size() - 3) / 3
                        : Integer.MAX_VALUE
                  );

                  for (int $i = 0; $i < this.policyUriTranslations$key.size(); $i++) {
                     policyUriTranslations.put(this.policyUriTranslations$key.get($i), this.policyUriTranslations$value.get($i));
                  }

                  yield Collections.unmodifiableMap(policyUriTranslations);
               }
            },
            this.softwareId,
            this.softwareVersion
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2ClientRegistrationResponseData.OAuth2ClientRegistrationResponseDataBuilder(techClientId="
            + this.techClientId
            + ", clientId="
            + this.clientId
            + ", clientSecret="
            + this.clientSecret
            + ", clientName="
            + this.clientName
            + ", clientNameTranslations$key="
            + this.clientNameTranslations$key
            + ", clientNameTranslations$value="
            + this.clientNameTranslations$value
            + ", clientIdIssuedAt="
            + this.clientIdIssuedAt
            + ", redirectUris="
            + this.redirectUris
            + ", tokenEndpointAuthMethod="
            + this.tokenEndpointAuthMethod
            + ", grantTypes="
            + this.grantTypes
            + ", responseTypes="
            + this.responseTypes
            + ", clientUri="
            + this.clientUri
            + ", clientUriTranslations$key="
            + this.clientUriTranslations$key
            + ", clientUriTranslations$value="
            + this.clientUriTranslations$value
            + ", logoUri="
            + this.logoUri
            + ", logoUriTranslations$key="
            + this.logoUriTranslations$key
            + ", logoUriTranslations$value="
            + this.logoUriTranslations$value
            + ", scopes="
            + this.scopes
            + ", contacts="
            + this.contacts
            + ", tosUri="
            + this.tosUri
            + ", tosUriTranslations$key="
            + this.tosUriTranslations$key
            + ", tosUriTranslations$value="
            + this.tosUriTranslations$value
            + ", policyUri="
            + this.policyUri
            + ", policyUriTranslations$key="
            + this.policyUriTranslations$key
            + ", policyUriTranslations$value="
            + this.policyUriTranslations$value
            + ", softwareId="
            + this.softwareId
            + ", softwareVersion="
            + this.softwareVersion
            + ")";
      }
   }

   private static class OAuth2ClientSecretMapifier {
      private static final String EXPIRES_AT_KEY = "expiresAt";
      private static final String SECRET_KEY = "secret";

      public static OAuth2ClientSecret demapify(MapifiedValues values) {
         return values.containsKey("expiresAt")
            ? new OAuth2ClientSecret(values.get("secret"), values.demapifyValue("expiresAt", MapificationUtils::demapifyInstant))
            : new OAuth2ClientSecret(values.get("secret"));
      }

      public static MapifiedValues mapify(OAuth2ClientSecret secret) {
         return MapifiedValuesBuilder.mapifiedValues()
            .put("secret", secret.getSecret())
            .putIfPresent("expiresAt", secret.getExpiresAt().map(MapificationUtils::mapifyInstant))
            .build();
      }
   }

   private static class TechClientIdentityMapifier {
      public static Identity<TechnicalClient> demapify(MapifiedValues values) {
         return TechClientIdentityFactory.techClientId(values.get("techClientId"));
      }

      public static MapifiedValues mapify(Identity<TechnicalClient> techClientId) {
         return MapifiedValuesBuilder.mapifiedValues().put("techClientId", techClientId.asString()).build();
      }
   }
}
