- java.lang.Object
-
- javax.ws.rs.core.Variant.VariantListBuilder
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
VariantListBuilder()
Protected constructor, use the staticnewInstance
method to obtain an instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description 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.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.VariantListBuilder
encodings(String... encodings)
Set the encoding(s) for this variant.abstract Variant.VariantListBuilder
languages(Locale... languages)
Set the language(s) for this variant.abstract Variant.VariantListBuilder
mediaTypes(MediaType... mediaTypes)
Set the media type(s) for this variant.static Variant.VariantListBuilder
newInstance()
Create a new builder instance.
-
-
-
Constructor Detail
-
VariantListBuilder
protected VariantListBuilder()
Protected constructor, use the staticnewInstance
method to obtain an instance.
-
-
Method Detail
-
newInstance
public static Variant.VariantListBuilder newInstance()
Create a new builder instance.- Returns:
- a new builder instance.
-
build
public 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. 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 five (4 + 1) members:List
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
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.
-
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.
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/ws/rs/core/variant.variantlistbuilder.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.