javax.ws.rs.core

Class Variant.VariantListBuilder

  • Enclosing class:
    Variant

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

      • VariantListBuilder

        protected VariantListBuilder()
        Protected constructor, use the static newInstance 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.

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 15:09:26 Cette version de la page est en cache (à la date du 21/08/2025 15:09:26) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/ws/rs/core/Variant.VariantListBuilder.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, Variant.VariantListBuilder (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.