Enum Class RestContentType
- All Implemented Interfaces:
Serializable,Comparable<RestContentType>,Constable
Defines the supported content types for REST service requests and responses.
- Since:
- 1.0
- Author:
- Bonitasoft
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionBinary/octet-stream content type (application/octet-stream).Form URL encoded content type (application/x-www-form-urlencoded).JSON content type (application/json).Multipart form data content type (multipart/form-data).PDF content type (application/pdf).HTML content type (text/html).Plain text content type (text/plain).XML content type (application/xml). -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<RestContentType>fromMimeType(String mimeType) Finds a content type by its MIME type (case-insensitive).Retrieves all content types as a read-only Map.Retrieves all MIME types as a read-only List.Gets a brief description of the content type.getKey()Alias for getMimeType() to maintain consistency with other enums.Gets the MIME type string.booleanisJson()Checks if this content type is JSON.booleanChecks if this content type is text-based (can be logged as string).static booleanChecks if a given MIME type corresponds to a valid content type.booleanisXml()Checks if this content type is XML.static RestContentTypeReturns the enum constant of this class with the specified name.static RestContentType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
JSON
JSON content type (application/json). -
XML
XML content type (application/xml). -
TEXT_PLAIN
Plain text content type (text/plain). -
TEXT_HTML
HTML content type (text/html). -
FORM_URLENCODED
Form URL encoded content type (application/x-www-form-urlencoded). -
MULTIPART_FORM_DATA
Multipart form data content type (multipart/form-data). -
BINARY
Binary/octet-stream content type (application/octet-stream). -
PDF
PDF content type (application/pdf).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getMimeType
Gets the MIME type string.- Returns:
- The MIME type (e.g., "application/json")
-
getKey
Alias for getMimeType() to maintain consistency with other enums.- Returns:
- The MIME type string
-
getDescription
Gets a brief description of the content type.- Returns:
- The description
-
isValid
Checks if a given MIME type corresponds to a valid content type.- Parameters:
input- The MIME type to validate (case-insensitive)- Returns:
trueif the MIME type is valid
-
fromMimeType
Finds a content type by its MIME type (case-insensitive).- Parameters:
mimeType- The MIME type to search for- Returns:
- Optional containing the matching content type, or empty if not found
-
getAllData
Retrieves all content types as a read-only Map.- Returns:
- A map containing all content type data (MimeType -> Description)
-
getAllKeysList
Retrieves all MIME types as a read-only List.- Returns:
- A list containing all MIME type strings
-
isTextBased
public boolean isTextBased()Checks if this content type is text-based (can be logged as string).- Returns:
trueif the content is text-based
-
isJson
public boolean isJson()Checks if this content type is JSON.- Returns:
trueif this is JSON content type
-
isXml
public boolean isXml()Checks if this content type is XML.- Returns:
trueif this is XML content type
-