Interface ContentType
-
- All Superinterfaces:
java.lang.Comparable<ContentType>
@ProviderType public interface ContentType extends java.lang.Comparable<ContentType>
An interface that models a content type used by the framework to do the content negotation in order to choose the HypermediaConverter to be used to serialize the model.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getPrimary()
Get the primary segment of the content type.float
getQuality()
Gets the quality specified for the content type.java.lang.String
getSecondary()
Get the secondary segment of the content type.int
getTokenScore()
Returns the token score for the ContentType.java.lang.String
getType()
Get the type defined in the content type instance.boolean
isWildCard()
Determines whether the ContentType represents a wildcard.boolean
matches(java.lang.String type)
Determines whether the ContentType is a match for the provided content type string.
-
-
-
Method Detail
-
matches
boolean matches(java.lang.String type)
Determines whether the ContentType is a match for the provided content type string.- Parameters:
type
- The content type string that is matched against this instance.- Returns:
- Whether or not the current instance matches with the content type string.
-
getQuality
float getQuality()
Gets the quality specified for the content type. For example for the content type application/json;q=0.8 the quality would be 0.8.- Returns:
- The quality.
-
getPrimary
java.lang.String getPrimary()
Get the primary segment of the content type. For example, for the content type application/json;q=0.8 the primary segment would be application.- Returns:
- The primary segment.
-
getSecondary
java.lang.String getSecondary()
Get the secondary segment of the content type. For example, for the content type application/json;q=0.8 the secondary segment would be json.- Returns:
- The secondary segment.
-
getType
java.lang.String getType()
Get the type defined in the content type instance. For example, for the content type application/json;q=0.8 the type would be application/json.- Returns:
- The type.
-
isWildCard
boolean isWildCard()
Determines whether the ContentType represents a wildcard. A wildcard content type has a type of*\/*
.- Returns:
- Whether the ContentType is a wildcard.
-
getTokenScore
int getTokenScore()
Returns the token score for the ContentType. The token score is a measure of how detailed the content type is. A content that provides a primary and secondary segment (not a wildcard), as well as a quality and any other parameters will have a higher token score than a ContentType that does not. The framework prioritizes matches on a ContentType with higher token scores than those with lower token scores.- Returns:
- Token score
-
-