Class VariantListBuilder

    • Constructor Detail

      • VariantListBuilder

        public VariantListBuilder()
    • Method Detail

      • build

        public List<Variant> build()
        Description copied from class: Variant.VariantListBuilder
        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.
        Specified by:
        build in class Variant.VariantListBuilder
        Returns:
        a list of representation variants.
      • add

        public VariantListBuilder add()
        Description copied from class: Variant.VariantListBuilder
        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<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()
         
        Specified by:
        add in class Variant.VariantListBuilder
        Returns:
        the updated builder.