@Test public void testEnhanceWithQualityParameter() { Map<String, String> result; result = Quality.enhanceWithQualityParameter(null, "q", 1000); assertThat(result, equalTo(null)); result = Quality.enhanceWithQualityParameter(null, "q", 200); assertThat(result, equalTo(asMap("q=0.2"))); result = Quality.enhanceWithQualityParameter(null, "q", 220); assertThat(result, equalTo(asMap("q=0.22"))); result = Quality.enhanceWithQualityParameter(null, "q", 222); assertThat(result, equalTo(asMap("q=0.222"))); Map<String, String> parameters; parameters = asMap("a=b"); result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); assertThat(result, equalTo(parameters)); result = Quality.enhanceWithQualityParameter(parameters, "q", 200); assertThat(result, equalTo(asMap("a=b;q=0.2"))); result = Quality.enhanceWithQualityParameter(parameters, "q", 220); assertThat(result, equalTo(asMap("a=b;q=0.22"))); result = Quality.enhanceWithQualityParameter(parameters, "q", 222); assertThat(result, equalTo(asMap("a=b;q=0.222"))); parameters = asMap("a=b;q=0.3"); result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); assertThat(result, equalTo(asMap("a=b;q=1.0"))); result = Quality.enhanceWithQualityParameter(parameters, "q", 200); assertThat(result, equalTo(asMap("a=b;q=0.2"))); result = Quality.enhanceWithQualityParameter(parameters, "q", 220); assertThat(result, equalTo(asMap("a=b;q=0.22"))); result = Quality.enhanceWithQualityParameter(parameters, "q", 222); assertThat(result, equalTo(asMap("a=b;q=0.222"))); }
static Map<String, String> enhanceWithQualityParameter( final Map<String, String> parameters, final String qualityParamName, final int quality) { if (quality == DEFAULT) { if (parameters == null || parameters.isEmpty() || !parameters.containsKey(qualityParamName)) { return parameters; } } if (parameters == null || parameters.isEmpty()) { return Collections.singletonMap(qualityParamName, qualityValueToString(quality)); } try { parameters.put(qualityParamName, qualityValueToString(quality)); return parameters; } catch (final UnsupportedOperationException uoe) { final Map<String, String> result = new HashMap<String, String>(parameters); result.put(qualityParamName, qualityValueToString(quality)); return result; } }
Quality { static Map<String, String> enhanceWithQualityParameter( final Map<String, String> parameters, final String qualityParamName, final int quality) { if (quality == DEFAULT) { if (parameters == null || parameters.isEmpty() || !parameters.containsKey(qualityParamName)) { return parameters; } } if (parameters == null || parameters.isEmpty()) { return Collections.singletonMap(qualityParamName, qualityValueToString(quality)); } try { parameters.put(qualityParamName, qualityValueToString(quality)); return parameters; } catch (final UnsupportedOperationException uoe) { final Map<String, String> result = new HashMap<String, String>(parameters); result.put(qualityParamName, qualityValueToString(quality)); return result; } } }
Quality { static Map<String, String> enhanceWithQualityParameter( final Map<String, String> parameters, final String qualityParamName, final int quality) { if (quality == DEFAULT) { if (parameters == null || parameters.isEmpty() || !parameters.containsKey(qualityParamName)) { return parameters; } } if (parameters == null || parameters.isEmpty()) { return Collections.singletonMap(qualityParamName, qualityValueToString(quality)); } try { parameters.put(qualityParamName, qualityValueToString(quality)); return parameters; } catch (final UnsupportedOperationException uoe) { final Map<String, String> result = new HashMap<String, String>(parameters); result.put(qualityParamName, qualityValueToString(quality)); return result; } } private  Quality(); }
Quality { static Map<String, String> enhanceWithQualityParameter( final Map<String, String> parameters, final String qualityParamName, final int quality) { if (quality == DEFAULT) { if (parameters == null || parameters.isEmpty() || !parameters.containsKey(qualityParamName)) { return parameters; } } if (parameters == null || parameters.isEmpty()) { return Collections.singletonMap(qualityParamName, qualityValueToString(quality)); } try { parameters.put(qualityParamName, qualityValueToString(quality)); return parameters; } catch (final UnsupportedOperationException uoe) { final Map<String, String> result = new HashMap<String, String>(parameters); result.put(qualityParamName, qualityValueToString(quality)); return result; } } private  Quality();  }
Quality { static Map<String, String> enhanceWithQualityParameter( final Map<String, String> parameters, final String qualityParamName, final int quality) { if (quality == DEFAULT) { if (parameters == null || parameters.isEmpty() || !parameters.containsKey(qualityParamName)) { return parameters; } } if (parameters == null || parameters.isEmpty()) { return Collections.singletonMap(qualityParamName, qualityValueToString(quality)); } try { parameters.put(qualityParamName, qualityValueToString(quality)); return parameters; } catch (final UnsupportedOperationException uoe) { final Map<String, String> result = new HashMap<String, String>(parameters); result.put(qualityParamName, qualityValueToString(quality)); return result; } } private  Quality();  static final Comparator<Qualified> QUALIFIED_COMPARATOR; static final Comparator<Integer> QUALITY_VALUE_COMPARATOR; static final String QUALITY_PARAMETER_NAME; static final String QUALITY_SOURCE_PARAMETER_NAME; static final int MINIMUM; static final int MAXIMUM; static final int DEFAULT; }