package com.airlock.iam.oauth2.domain.model.claims;

import com.airlock.iam.oauth2.api.domain.model.OAuth2Scope;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Set;
import java.util.function.Function;

public enum ScopeFormat {
   SPACE_SEPARATED_STRING(scopes -> String.join(" ", OAuth2Scope.convertToScopeNames(scopes))),
   STRING_ARRAY(OAuth2Scope::convertToScopeNames);

   private final Function<Set<OAuth2Scope>, Object> scopeClaimTransformation;

   public Object getScopeClaimValue(Set<OAuth2Scope> scopes) {
      return this.scopeClaimTransformation.apply(scopes);
   }

   @SuppressFBWarnings(justification = "generated code")
   ScopeFormat(final Function<Set<OAuth2Scope>, Object> scopeClaimTransformation) {
      this.scopeClaimTransformation = scopeClaimTransformation;
   }
}
