package com.qmth.boot.api.config;

import com.qmth.boot.api.constant.ApiConstant;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotBlank;

@Component
@ConfigurationProperties(prefix = ApiConstant.CONFIG_PREFIX)
@Validated
public class ApiProperties implements ApiConstant {

    @NotBlank
    private String uriPrefix = DEFAULT_URI_PREFIX;

    private boolean errorMapping = true;

    private boolean globalStrict = false;

    private boolean globalAuth = false;

    @Nullable
    private String[] globalRateLimit = null;

    private boolean httpTrace = false;

    public String getUriPrefix() {
        return uriPrefix;
    }

    public void setUriPrefix(String uriPrefix) {
        this.uriPrefix = uriPrefix;
    }

    public boolean isErrorMapping() {
        return errorMapping;
    }

    public void setErrorMapping(boolean errorMapping) {
        this.errorMapping = errorMapping;
    }

    public boolean isGlobalStrict() {
        return globalStrict;
    }

    public void setGlobalStrict(boolean globalStrict) {
        this.globalStrict = globalStrict;
    }

    public boolean isGlobalAuth() {
        return globalAuth;
    }

    @Nullable
    public String[] getGlobalRateLimit() {
        return globalRateLimit;
    }

    public void setGlobalRateLimit(@Nullable String[] globalRateLimit) {
        this.globalRateLimit = globalRateLimit;
    }

    public void setGlobalAuth(boolean globalAuth) {
        this.globalAuth = globalAuth;
    }

    public boolean isHttpTrace() {
        return httpTrace;
    }

    public void setHttpTrace(boolean httpTrace) {
        this.httpTrace = httpTrace;
    }

}
