MediaType.java (spring-framework-5.3.23) | : | MediaType.java (spring-framework-5.3.24) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2002-2021 the original author or authors. | * Copyright 2002-2022 the original author or authors. | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
skipping to change at line 531 | skipping to change at line 531 | |||
*/ | */ | |||
public MediaType(MimeType mimeType) { | public MediaType(MimeType mimeType) { | |||
super(mimeType); | super(mimeType); | |||
getParameters().forEach(this::checkParameters); | getParameters().forEach(this::checkParameters); | |||
} | } | |||
@Override | @Override | |||
protected void checkParameters(String parameter, String value) { | protected void checkParameters(String parameter, String value) { | |||
super.checkParameters(parameter, value); | super.checkParameters(parameter, value); | |||
if (PARAM_QUALITY_FACTOR.equals(parameter)) { | if (PARAM_QUALITY_FACTOR.equals(parameter)) { | |||
value = unquote(value); | String unquotedValue = unquote(value); | |||
double d = Double.parseDouble(value); | double d = Double.parseDouble(unquotedValue); | |||
Assert.isTrue(d >= 0D && d <= 1D, | Assert.isTrue(d >= 0D && d <= 1D, | |||
"Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); | () -> "Invalid quality value \"" + unquot edValue + "\": should be between 0.0 and 1.0"); | |||
} | } | |||
} | } | |||
/** | /** | |||
* Return the quality factor, as indicated by a {@code q} parameter, if a ny. | * Return the quality factor, as indicated by a {@code q} parameter, if a ny. | |||
* Defaults to {@code 1.0}. | * Defaults to {@code 1.0}. | |||
* @return the quality factor as double value | * @return the quality factor as double value | |||
*/ | */ | |||
public double getQualityValue() { | public double getQualityValue() { | |||
String qualityFactor = getParameter(PARAM_QUALITY_FACTOR); | String qualityFactor = getParameter(PARAM_QUALITY_FACTOR); | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |