Class Variant.VariantListBuilder

java.lang.Object
javax.ws.rs.core.Variant.VariantListBuilder
Enclosing class:
Variant

public abstract static class Variant.VariantListBuilder extends Object
A builder for a list of representation variants.
  • Constructor Details

    • VariantListBuilder

      protected VariantListBuilder()
      Protected constructor, use the static newInstance method to obtain an instance.
  • Method Details

    • newInstance

      public static Variant.VariantListBuilder newInstance()
      Create a new builder instance.
      Returns:
      a new Builder
    • build

      public abstract List<Variant> build()
      Build a list of representation variants from the current state of the builder. After this method is called the builder is reset to an empty state.
      Returns:
      a list of representation variants
    • add

      public abstract Variant.VariantListBuilder add()
      Add the current combination of metadata to the list of supported variants, after this method is called the current combination of metadata is emptied. If more than one value is supplied for one or more of the variant properties then a variant will be generated for each possible combination. E.g. in the following list would have four members:

      List list = VariantListBuilder.newInstance().languages("en","fr")
         .encodings("zip", "identity").add().build()
      Returns:
      the updated builder
      Throws:
      IllegalStateException - if there is not at least one mediaType, language or encoding set for the current variant.
    • languages

      public abstract Variant.VariantListBuilder languages(Locale... languages)
      Set the language[s] for this variant.
      Parameters:
      languages - the available languages
      Returns:
      the updated builder
    • encodings

      public abstract Variant.VariantListBuilder encodings(String... encodings)
      Set the encoding[s] for this variant.
      Parameters:
      encodings - the available encodings
      Returns:
      the updated builder
    • mediaTypes

      public abstract Variant.VariantListBuilder mediaTypes(MediaType... mediaTypes)
      Set the media type[s] for this variant.
      Parameters:
      mediaTypes - the available mediaTypes. If specific charsets are supported they should be included as parameters of the respective media type.
      Returns:
      the updated builder