package com.spring.domain.user.entity;

import java.util.Arrays;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum AgentUserRole {
    
    ROLE_SUPER("ROLE_SUPER", "슈퍼관리자"),
    ROLE_ADMIN("ROLE_ADMIN", "관리자"),
    ROLE_USER("ROLE_USER", "사용자");

    @JsonValue
    private final String role;
    private final String roleName;

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static AgentUserRole fromRole(String role) {
        return Arrays.stream(values())
                    .filter(value -> value.getRole().equalsIgnoreCase(role))
                    .findFirst()
                    .orElse(null);
    }

}
