public enum MediaType extends Enum<MediaType>
The MediaType
describes the types of media this application can handle and render.
The media type is a closed set - as each different type of media requires support coded into the view layers, it
cannot be expanded upon without rebuilding the application. It is therefore represented by an enumeration. When used, you
should instruct JPA to store the enum value using it's String representation, so that we can later reorder the enum members,
without changing the data. Of course, this does mean we can't change the names of media items once the app is put into
production. To do this add @Enumerated(STRING)
to the field declaration.
The MediaType
also describes whether this type of media can be cached locally, and used when there is no internet
connection. For example images and or an mpeg video file can be cached, whilst a video streamed across the internet cannot.
Enum Constant and Description |
---|
IMAGE
The types of media the application can currently handle.
|
Modifier and Type | Method and Description |
---|---|
String |
getDescription() |
boolean |
isCacheable() |
static MediaType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static MediaType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final MediaType IMAGE
public static MediaType[] values()
for (MediaType c : MediaType.values()) System.out.println(c);
public static MediaType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String getDescription()
public boolean isCacheable()
Copyright © 2016. All rights reserved.