public class MediaType extends java.lang.Object implements Compatible<MediaType>
| Modifier and Type | Field and Description |
|---|---|
static MediaType |
ANY |
static MediaType |
APPLICATION_ANY |
static MediaType |
APPLICATION_HAL_JSON |
static MediaType |
APPLICATION_HAL_XML |
static MediaType |
APPLICATION_JSON |
static MediaType |
APPLICATION_XML |
| Constructor and Description |
|---|
MediaType(java.lang.String type) |
MediaType(java.lang.String type,
java.lang.String subType) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
compatible(MediaType other)
Return true if this
Compatible instance
could be safely replaced
with the supplied other
Compatible
Note compatibility is not symmetric
x.compatible(y) does NOT mean
y.compatible(x). |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
static MediaType |
parse(java.lang.String mediaType) |
java.lang.String |
subType() |
java.lang.String |
toString() |
java.lang.String |
type() |
public static final MediaType ANY
public static final MediaType APPLICATION_ANY
public static final MediaType APPLICATION_JSON
public static final MediaType APPLICATION_XML
public static final MediaType APPLICATION_HAL_JSON
public static final MediaType APPLICATION_HAL_XML
public MediaType(java.lang.String type,
java.lang.String subType)
public MediaType(java.lang.String type)
public java.lang.String type()
public java.lang.String subType()
public boolean compatible(MediaType other)
CompatibleCompatible instance
could be safely replaced
with the supplied other
Compatible
Note compatibility is not symmetric
x.compatible(y) does NOT mean
y.compatible(x). Example:
application/json is compatible with (can replace) application/*
application/* is not compatible with (cannot replace) application/json
wildcard.compatible(json) = true
json.compatible(wildcard) = false
Neither is it transitive.
x.compatible(y) and z.compatible(y)
does not imply z.compatible(z). Example:
application/json is compatible with application/*
application/xml is compatible with application/*
application/xml is not compatible with application/jsoncompatible in interface Compatible<MediaType>other - another Compatible instanceCompatible could be replaced by the otherpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic static MediaType parse(java.lang.String mediaType)