package com.github.mkopylec.errorest.configuration;

import com.github.mkopylec.errorest.logging.LoggingLevel;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import static com.github.mkopylec.errorest.configuration.ErrorestProperties.ResponseBodyFormat.FULL;
import static com.github.mkopylec.errorest.logging.LoggingLevel.WARN;

/**
 * ErroREST configuration properties.
 */
@ConfigurationProperties("errorest")
public class ErrorestProperties {

    /**
     * HTTP response body format.
     */
    private ResponseBodyFormat responseBodyFormat = FULL;
    /**
     * Properties responsible for handling validation errors.
     */
    @NestedConfigurationProperty
    private BeanValidationError beanValidationError = new BeanValidationError();
    /**
     * Properties responsible for handling 4xx HTTP errors.
     */
    @NestedConfigurationProperty
    private HttpClientError httpClientError = new HttpClientError();

    public ResponseBodyFormat getResponseBodyFormat() {
        return responseBodyFormat;
    }

    public void setResponseBodyFormat(ResponseBodyFormat responseBodyFormat) {
        this.responseBodyFormat = responseBodyFormat;
    }

    public BeanValidationError getBeanValidationError() {
        return beanValidationError;
    }

    public void setBeanValidationError(BeanValidationError beanValidationError) {
        this.beanValidationError = beanValidationError;
    }

    public HttpClientError getHttpClientError() {
        return httpClientError;
    }

    public void setHttpClientError(HttpClientError httpClientError) {
        this.httpClientError = httpClientError;
    }

    public enum ResponseBodyFormat {
        WITHOUT_DESCRIPTIONS, FULL
    }

    public static class BeanValidationError {

        /**
         * Validation errors logging level.
         */
        private LoggingLevel loggingLevel = WARN;

        public LoggingLevel getLoggingLevel() {
            return loggingLevel;
        }

        public void setLoggingLevel(LoggingLevel loggingLevel) {
            this.loggingLevel = loggingLevel;
        }
    }

    public static class HttpClientError {

        /**
         * HTTP 4xx errors logging level.
         */
        private LoggingLevel loggingLevel = WARN;

        public LoggingLevel getLoggingLevel() {
            return loggingLevel;
        }

        public void setLoggingLevel(LoggingLevel loggingLevel) {
            this.loggingLevel = loggingLevel;
        }
    }
}

@@ -183,88 +183,8 @@
 ies;
-%0Aimport org.springframework.boot.context.properties.NestedConfigurationProperty;
 %0A%0Aim
@@ -661,41 +661,8 @@
  */%0A
-    @NestedConfigurationProperty%0A
     
@@ -818,41 +818,8 @@
  */%0A
-    @NestedConfigurationProperty%0A
     

Remove unnecessary NestedConfigurationProperty