code: private static boolean isBetterOption(BigDecimal bestQuality, Variant best,
                                           BigDecimal optionQuality, Variant option)
     {
        if (best == null)
           return true;
        MediaType bestType = best.getMediaType();
        MediaType optionType = option.getMediaType();
        if (bestType != null && optionType != null)
        {
           if (bestType.getType().equals(optionType.getType()))
           {
              // Same type
              if (bestType.getSubtype().equals(optionType.getSubtype()))
              {
                 // Same subtype
                 int bestCount = bestType.getParameters().size();
                 int optionCount = optionType.getParameters().size();
                 if (optionCount > bestCount)
                    return true;   // more matching parameters
                 else if (optionCount < bestCount)
                    return false;   // less matching parameters
              }
              else if ("*".equals(bestType.getSubtype()))
              {
                 return true;   // more specific subtype
              }
              else if ("*".equals(optionType.getSubtype()))
              {
                 return false;   // less specific subtype
              }
           }
           else if ("*".equals(bestType.getType()))
           {
              return true;   // more specific type
           }
           else if ("*".equals(optionType.getType()))
           {
              return false;   // less specific type;
           }
        }
  
        int signum = bestQuality.compareTo(optionQuality);
        if (signum != 0)
           return signum < 0;
        return getExplicitness(best) < getExplicitness(option);
     }
docs: Tests whether {@code option} is preferable over the current {@code bestOption}.