Skip to content

Commit

Permalink
Deprecate Charsets constants.
Browse files Browse the repository at this point in the history
RELNOTES=`base: Deprecated `Charsets` constants in favor of `StandardCharsets`.
PiperOrigin-RevId: 699971004
  • Loading branch information
kluever authored and Google Java Core Libraries committed Nov 25, 2024
1 parent 4d4b29c commit 45e6be2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 70 deletions.
48 changes: 13 additions & 35 deletions android/guava/src/com/google/common/base/Charsets.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,75 +35,53 @@
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Charsets {
private Charsets() {}

/**
* US-ASCII: seven-bit ASCII, the Basic Latin block of the Unicode character set (ISO646-US).
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#US_ASCII} instead.
*
* @deprecated Use {@link StandardCharsets#US_ASCII} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset US_ASCII = StandardCharsets.US_ASCII;

/**
* ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#ISO_8859_1} instead.
*
* @deprecated Use {@link StandardCharsets#ISO_8859_1} instead.
*/
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
@Deprecated public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;

/**
* UTF-8: eight-bit UCS Transformation Format.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_8} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_8} instead.
*/
public static final Charset UTF_8 = StandardCharsets.UTF_8;
@Deprecated public static final Charset UTF_8 = StandardCharsets.UTF_8;

/**
* UTF-16BE: sixteen-bit UCS Transformation Format, big-endian byte order.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16BE} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16BE} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;

/**
* UTF-16LE: sixteen-bit UCS Transformation Format, little-endian byte order.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16LE} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16LE} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;

/**
* UTF-16: sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order
* mark.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16 = StandardCharsets.UTF_16;

/*
* Please do not add new Charset references to this class, unless those character encodings are
* part of the set required to be supported by all Java platform implementations! Any Charsets
* initialized here may cause unexpected delays when this class is loaded. See the Charset
* Javadocs for the list of built-in character encodings.
*/
private Charsets() {}
}
48 changes: 13 additions & 35 deletions guava/src/com/google/common/base/Charsets.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,75 +35,53 @@
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Charsets {
private Charsets() {}

/**
* US-ASCII: seven-bit ASCII, the Basic Latin block of the Unicode character set (ISO646-US).
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#US_ASCII} instead.
*
* @deprecated Use {@link StandardCharsets#US_ASCII} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset US_ASCII = StandardCharsets.US_ASCII;

/**
* ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#ISO_8859_1} instead.
*
* @deprecated Use {@link StandardCharsets#ISO_8859_1} instead.
*/
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
@Deprecated public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;

/**
* UTF-8: eight-bit UCS Transformation Format.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_8} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_8} instead.
*/
public static final Charset UTF_8 = StandardCharsets.UTF_8;
@Deprecated public static final Charset UTF_8 = StandardCharsets.UTF_8;

/**
* UTF-16BE: sixteen-bit UCS Transformation Format, big-endian byte order.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16BE} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16BE} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;

/**
* UTF-16LE: sixteen-bit UCS Transformation Format, little-endian byte order.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16LE} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16LE} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;

/**
* UTF-16: sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order
* mark.
*
* <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
* {@link StandardCharsets#UTF_16} instead.
*
* @deprecated Use {@link StandardCharsets#UTF_16} instead.
*/
@J2ktIncompatible
@GwtIncompatible // Charset not supported by GWT
@Deprecated @J2ktIncompatible @GwtIncompatible // Charset not supported by GWT
public static final Charset UTF_16 = StandardCharsets.UTF_16;

/*
* Please do not add new Charset references to this class, unless those character encodings are
* part of the set required to be supported by all Java platform implementations! Any Charsets
* initialized here may cause unexpected delays when this class is loaded. See the Charset
* Javadocs for the list of built-in character encodings.
*/
private Charsets() {}
}

0 comments on commit 45e6be2

Please sign in to comment.