Class Variant.VariantListBuilder

  • Enclosing class:
    Variant

    public abstract static class Variant.VariantListBuilder
    extends java.lang.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

      • build

        public abstract java.util.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:
        java.lang.IllegalStateException - if there is not at least one mediaType, language or encoding set for the current variant.
      • languages

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

        public abstract Variant.VariantListBuilder encodings​(java.lang.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