Package jakarta.ws.rs.core
Class Variant.VariantListBuilder
java.lang.Object
jakarta.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 SummaryConstructors Modifier Constructor Description protectedVariantListBuilder()Protected constructor, use the staticnewInstancemethod to obtain an instance.
- 
Method SummaryModifier and Type Method Description abstract Variant.VariantListBuilderadd()Add the current combination of metadata to the list of supported variants, after this method is called the current combination of metadata is emptied.abstract List<Variant>build()Add the current combination of metadata to the list of supported variants (provided the current combination of metadata is not empty) and build a list of representation variants from the current state of the builder.abstract Variant.VariantListBuilderencodings(String... encodings)Set the encoding(s) for this variant.abstract Variant.VariantListBuilderlanguages(Locale... languages)Set the language(s) for this variant.abstract Variant.VariantListBuildermediaTypes(MediaType... mediaTypes)Set the media type(s) for this variant.static Variant.VariantListBuildernewInstance()Create a new builder instance.
- 
Constructor Details- 
VariantListBuilderprotected VariantListBuilder()Protected constructor, use the staticnewInstancemethod to obtain an instance.
 
- 
- 
Method Details- 
newInstanceCreate a new builder instance.- Returns:
- a new builder instance.
 
- 
buildAdd the current combination of metadata to the list of supported variants (provided the current combination of metadata is not empty) and 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.
 
- 
addAdd 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 listwould have five (4 + 1) members:List<Variant> list = VariantListBuilder.newInstance() .languages(Locale.ENGLISH, Locale.FRENCH).encodings("zip", "identity").add() .languages(Locale.GERMAN).mediaTypes(MediaType.TEXT_PLAIN_TYPE).add() .build()Note that it is not necessary to call the add()method immediately before the build method is called. E.g. the resulting list produced in the example above would be identical to the list produced by the following code:List<Variant> list = VariantListBuilder.newInstance() .languages(Locale.ENGLISH, Locale.FRENCH).encodings("zip", "identity").add() .languages(Locale.GERMAN).mediaTypes(MediaType.TEXT_PLAIN_TYPE) .build()- Returns:
- the updated builder.
- Throws:
- IllegalStateException- if there is not at least one mediaType, language or encoding set for the current variant.
 
- 
languagesSet the language(s) for this variant.- Parameters:
- languages- the available languages.
- Returns:
- the updated builder.
 
- 
encodingsSet the encoding(s) for this variant.- Parameters:
- encodings- the available encodings.
- Returns:
- the updated builder.
 
- 
mediaTypesSet 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.
 
 
-