Class VariantSelector


  • public final class VariantSelector
    extends java.lang.Object
    Utility for selecting variant that best matches request from a list of variants.
    • Constructor Detail

      • VariantSelector

        private VariantSelector()
    • Method Detail

      • selectVariants

        private static <T extends Qualified,​U> java.util.LinkedList<VariantSelector.VariantHolder> selectVariants​(java.util.List<VariantSelector.VariantHolder> variantHolders,
                                                                                                                        java.util.List<T> acceptableValues,
                                                                                                                        VariantSelector.DimensionChecker<T,​U> dimensionChecker,
                                                                                                                        java.util.Set<java.lang.String> vary)
        Select variants for a given dimension.
        Parameters:
        variantHolders - collection of variants.
        acceptableValues - the list of acceptable dimension values, ordered by the quality parameter, with the highest quality dimension value occurring first.
        dimensionChecker - the dimension checker
        vary - output list of generated vary headers.
      • getVariantHolderList

        private static java.util.LinkedList<VariantSelector.VariantHolder> getVariantHolderList​(java.util.List<javax.ws.rs.core.Variant> variants)
      • selectVariant

        public static javax.ws.rs.core.Variant selectVariant​(InboundMessageContext context,
                                                             java.util.List<javax.ws.rs.core.Variant> variants,
                                                             Ref<java.lang.String> varyHeaderValue)
        Select the representation variant that best matches the request. More explicit variants are chosen ahead of less explicit ones.
        Parameters:
        context - inbound message context.
        variants - list of possible variants.
        varyHeaderValue - an output reference of vary header value that should be put into the response Vary header.
        Returns:
        selected variant.
      • selectVariants

        public static java.util.List<javax.ws.rs.core.Variant> selectVariants​(InboundMessageContext context,
                                                                              java.util.List<javax.ws.rs.core.Variant> variants,
                                                                              Ref<java.lang.String> varyHeaderValue)
        Select possible representation variants in order in which they best matches the request.
        Parameters:
        context - inbound message context.
        variants - list of possible variants.
        varyHeaderValue - an output reference of vary header value that should be put into the response Vary header.
        Returns:
        possible variants.