8318466: Improve spec of NumberFormat's methods with unsupported operations

Reviewed-by: naoto, iris
This commit is contained in:
Justin Lu 2023-11-03 17:32:51 +00:00
parent de6667cf11
commit ea6a88a0aa

View File

@ -897,16 +897,16 @@ public abstract class NumberFormat extends Format {
/** /**
* Gets the currency used by this number format when formatting * Gets the currency used by this number format when formatting
* currency values. The initial value is derived in a locale dependent * currency values. The initial value is derived in a locale dependent
* way. The returned value may be null if no valid * way. The returned value may be {@code null} if no valid
* currency could be determined and no currency has been set using * currency could be determined and no currency has been set using
* {@link #setCurrency(java.util.Currency) setCurrency}. * {@link #setCurrency(Currency)}.
* <p>
* The default implementation throws
* {@code UnsupportedOperationException}.
* *
* @implSpec The default implementation always throws {@code
* UnsupportedOperationException}. Subclasses should override this method
* if currency formatting is desired.
* @return the currency used by this number format, or {@code null} * @return the currency used by this number format, or {@code null}
* @throws UnsupportedOperationException if the number format class * @throws UnsupportedOperationException if the implementation of this
* doesn't implement currency formatting * method does not support this operation
* @since 1.4 * @since 1.4
*/ */
public Currency getCurrency() { public Currency getCurrency() {
@ -917,14 +917,14 @@ public abstract class NumberFormat extends Format {
* Sets the currency used by this number format when formatting * Sets the currency used by this number format when formatting
* currency values. This does not update the minimum or maximum * currency values. This does not update the minimum or maximum
* number of fraction digits used by the number format. * number of fraction digits used by the number format.
* <p>
* The default implementation throws
* {@code UnsupportedOperationException}.
* *
* @implSpec The default implementation always throws {@code
* UnsupportedOperationException}. Subclasses should override this method
* if currency formatting is desired.
* @param currency the new currency to be used by this number format * @param currency the new currency to be used by this number format
* @throws UnsupportedOperationException if the number format class * @throws NullPointerException if {@code currency} is {@code null}
* doesn't implement currency formatting * @throws UnsupportedOperationException if the implementation of this
* @throws NullPointerException if {@code currency} is null * method does not support this operation
* @since 1.4 * @since 1.4
*/ */
public void setCurrency(Currency currency) { public void setCurrency(Currency currency) {
@ -933,14 +933,13 @@ public abstract class NumberFormat extends Format {
/** /**
* Gets the {@link java.math.RoundingMode} used in this NumberFormat. * Gets the {@link java.math.RoundingMode} used in this NumberFormat.
* The default implementation of this method in NumberFormat
* always throws {@link java.lang.UnsupportedOperationException}.
* Subclasses which handle different rounding modes should override
* this method.
* *
* @throws UnsupportedOperationException The default implementation * @implSpec The default implementation always throws {@code
* always throws this exception * UnsupportedOperationException}. Subclasses which handle different
* rounding modes should override this method.
* @return The {@code RoundingMode} used for this NumberFormat. * @return The {@code RoundingMode} used for this NumberFormat.
* @throws UnsupportedOperationException if the implementation of this
* method does not support this operation
* @see #setRoundingMode(RoundingMode) * @see #setRoundingMode(RoundingMode)
* @since 1.6 * @since 1.6
*/ */
@ -950,14 +949,13 @@ public abstract class NumberFormat extends Format {
/** /**
* Sets the {@link java.math.RoundingMode} used in this NumberFormat. * Sets the {@link java.math.RoundingMode} used in this NumberFormat.
* The default implementation of this method in NumberFormat always
* throws {@link java.lang.UnsupportedOperationException}.
* Subclasses which handle different rounding modes should override
* this method.
* *
* @throws UnsupportedOperationException The default implementation * @implSpec The default implementation always throws {@code
* always throws this exception * UnsupportedOperationException}. Subclasses which handle different
* @throws NullPointerException if {@code roundingMode} is null * rounding modes should override this method.
* @throws NullPointerException if {@code roundingMode} is {@code null}
* @throws UnsupportedOperationException if the implementation of this
* method does not support this operation
* @param roundingMode The {@code RoundingMode} to be used * @param roundingMode The {@code RoundingMode} to be used
* @see #getRoundingMode() * @see #getRoundingMode()
* @since 1.6 * @since 1.6