Interface ContentType

All Superinterfaces:
Comparable<ContentType>

@ProviderType public interface ContentType extends 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

    Modifier and Type
    Method
    Description
    Get the primary segment of the content type.
    float
    Gets the quality specified for the content type.
    Get the secondary segment of the content type.
    int
    Returns the token score for the ContentType.
    Get the type defined in the content type instance.
    boolean
    Determines whether the ContentType represents a wildcard.
    boolean
    Determines whether the ContentType is a match for the provided content type string.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • matches

      boolean matches(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

      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

      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

      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