Created
January 25, 2026 20:46
-
-
Save boaglio/a4fd90daf3450511bd9162b743ce2cf7 to your computer and use it in GitHub Desktop.
SpringConstants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.boaglio.apivmvp; | |
| import org.springframework.http.HttpMethod; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.MediaType; | |
| import org.springframework.boot.actuate.health.Status; | |
| import org.springframework.boot.logging.LogLevel; | |
| public final class SpringConstants { | |
| private SpringConstants() { | |
| throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); | |
| } | |
| // ==================== HTTP METHODS ==================== | |
| public static final class HttpMethods { | |
| public static final String GET = HttpMethod.GET.name(); | |
| public static final String POST = HttpMethod.POST.name(); | |
| public static final String PUT = HttpMethod.PUT.name(); | |
| public static final String DELETE = HttpMethod.DELETE.name(); | |
| public static final String PATCH = HttpMethod.PATCH.name(); | |
| public static final String HEAD = HttpMethod.HEAD.name(); | |
| public static final String OPTIONS = HttpMethod.OPTIONS.name(); | |
| public static final String TRACE = HttpMethod.TRACE.name(); | |
| private HttpMethods() {} | |
| } | |
| // ==================== HTTP STATUS ==================== | |
| public static final class HttpStatuses { | |
| // 2xx Success | |
| public static final String OK = HttpStatus.OK.name(); | |
| public static final String CREATED = HttpStatus.CREATED.name(); | |
| public static final String ACCEPTED = HttpStatus.ACCEPTED.name(); | |
| public static final String NO_CONTENT = HttpStatus.NO_CONTENT.name(); | |
| // 3xx Redirection | |
| public static final String MOVED_PERMANENTLY = HttpStatus.MOVED_PERMANENTLY.name(); | |
| public static final String FOUND = HttpStatus.FOUND.name(); | |
| public static final String NOT_MODIFIED = HttpStatus.NOT_MODIFIED.name(); | |
| // 4xx Client Errors | |
| public static final String BAD_REQUEST = HttpStatus.BAD_REQUEST.name(); | |
| public static final String UNAUTHORIZED = HttpStatus.UNAUTHORIZED.name(); | |
| public static final String FORBIDDEN = HttpStatus.FORBIDDEN.name(); | |
| public static final String NOT_FOUND = HttpStatus.NOT_FOUND.name(); | |
| public static final String METHOD_NOT_ALLOWED = HttpStatus.METHOD_NOT_ALLOWED.name(); | |
| public static final String CONFLICT = HttpStatus.CONFLICT.name(); | |
| public static final String UNPROCESSABLE_ENTITY = HttpStatus.UNPROCESSABLE_ENTITY.name(); | |
| // 5xx Server Errors | |
| public static final String INTERNAL_SERVER_ERROR = HttpStatus.INTERNAL_SERVER_ERROR.name(); | |
| public static final String NOT_IMPLEMENTED = HttpStatus.NOT_IMPLEMENTED.name(); | |
| public static final String BAD_GATEWAY = HttpStatus.BAD_GATEWAY.name(); | |
| public static final String SERVICE_UNAVAILABLE = HttpStatus.SERVICE_UNAVAILABLE.name(); | |
| private HttpStatuses() {} | |
| } | |
| // ==================== MEDIA TYPES ==================== | |
| public static final class MediaTypes { | |
| public static final String APPLICATION_JSON = MediaType.APPLICATION_JSON_VALUE; | |
| public static final String APPLICATION_XML = MediaType.APPLICATION_XML_VALUE; | |
| public static final String APPLICATION_FORM_URLENCODED = MediaType.APPLICATION_FORM_URLENCODED_VALUE; | |
| public static final String MULTIPART_FORM_DATA = MediaType.MULTIPART_FORM_DATA_VALUE; | |
| public static final String TEXT_HTML = MediaType.TEXT_HTML_VALUE; | |
| public static final String TEXT_PLAIN = MediaType.TEXT_PLAIN_VALUE; | |
| public static final String TEXT_XML = MediaType.TEXT_XML_VALUE; | |
| public static final String APPLICATION_PDF = MediaType.APPLICATION_PDF_VALUE; | |
| public static final String IMAGE_JPEG = MediaType.IMAGE_JPEG_VALUE; | |
| public static final String IMAGE_PNG = MediaType.IMAGE_PNG_VALUE; | |
| public static final String APPLICATION_OCTET_STREAM = MediaType.APPLICATION_OCTET_STREAM_VALUE; | |
| private MediaTypes() {} | |
| } | |
| // ==================== LOGGING LEVELS ==================== | |
| public static final class LogLevels { | |
| public static final String TRACE = LogLevel.TRACE.name(); | |
| public static final String DEBUG = LogLevel.DEBUG.name(); | |
| public static final String INFO = LogLevel.INFO.name(); | |
| public static final String WARN = LogLevel.WARN.name(); | |
| public static final String ERROR = LogLevel.ERROR.name(); | |
| public static final String FATAL = LogLevel.FATAL.name(); | |
| public static final String OFF = LogLevel.OFF.name(); | |
| private LogLevels() {} | |
| } | |
| // ==================== ACTUATOR HEALTH STATUS ==================== | |
| public static final class HealthStatuses { | |
| public static final String UP = Status.UP.getCode(); | |
| public static final String DOWN = Status.DOWN.getCode(); | |
| public static final String OUT_OF_SERVICE = Status.OUT_OF_SERVICE.getCode(); | |
| public static final String UNKNOWN = Status.UNKNOWN.getCode(); | |
| private HealthStatuses() {} | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment