Enum

public abstract class Enum
extends Object implements Comparable<E extends Enum<E>>, Serializable

java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
AccessMode Defines access modes used to test the accessibility of a file. 
AclEntryFlag Defines the flags for used by the flags component of an ACL entry
AclEntryPermission Defines the permissions for use with the permissions component of an ACL entry
AclEntryType A typesafe enumeration of the access control entry types. 
Allocation.MipmapControl Controls mipmap behavior when using the bitmap creation and update functions. 
AlphabeticIndex.Bucket.LabelType Type of the label 
AsyncTask.Status Indicates the current status of the task. 
Authenticator.RequestorType The type of the entity requesting authentication. 
Bitmap.CompressFormat Specifies the known formats a bitmap can be compressed into 
Bitmap.Config Possible bitmap configurations. 
BlendMode  
BlurMaskFilter.Blur  
CRLReason The CRLReason enumeration specifies the reason that a certificate is revoked, as defined in RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile
Canvas.EdgeType This enum was deprecated in API level 30. quickReject no longer uses this. 
Canvas.VertexMode  
CertPathValidatorException.BasicReason The BasicReason enumerates the potential reasons that a certification path of any type may be invalid. 
Character.UnicodeScript A family of character subsets representing the character scripts defined in the Unicode Standard Annex #24: Script Names
ChronoField A standard set of fields. 
ChronoUnit A standard set of date periods units. 
ClientInfoStatus Enumeration for status of the reason that a property could not be set via a call to Connection.setClientInfo 
Collector.Characteristics Characteristics indicating properties of a Collector, which can be used to optimize reduction implementations. 
ColorSpace.Adaptation

List of adaptation matrices that can be used for chromatic adaptation using the von Kries transform. 

ColorSpace.Model A color model is required by a ColorSpace to describe the way colors can be represented as tuples of numbers. 
ColorSpace.Named

List of common, named color spaces. 

ColorSpace.RenderIntent

A render intent determines how a connector maps colors from one color space to another. 

CompactDecimalFormat.CompactStyle Style parameter for CompactDecimalFormat. 
ConsoleMessage.MessageLevel  
CryptoPrimitive An enumeration of cryptographic primitives. 
Currency.CurrencyUsage Currency Usage used for Decimal Format 
CursorJoiner.Result The result of a call to next(). 
DateFormat.BooleanAttribute boolean attributes 
DateFormat.HourCycle Hour Cycle 
DateTimePatternGenerator.DisplayWidth Field display name width constants for getFieldDisplayName 
DayOfWeek A day-of-week, such as 'Tuesday'. 
DisplayContext Display context settings. 
DisplayContext.Type Type values for DisplayContext 
DisplayOptions.Capitalization Represents all the capitalization options. 
DisplayOptions.DisplayLength Represents all the display lengths. 
DisplayOptions.GrammaticalCase Represents all the grammatical cases that are supported by CLDR. 
DisplayOptions.NameStyle Represents all the name styles. 
DisplayOptions.NounClass Represents all the grammatical noun classes that are supported by CLDR. 
DisplayOptions.PluralCategory Standard CLDR plural category constants. 
DisplayOptions.SubstituteHandling Represents all the substitute handlings. 
DrbgParameters.Capability The reseedable and prediction resistance capabilities of a DRBG. 
Element.DataKind The special interpretation of the data if required. 
Element.DataType DataType represents the basic type information for a basic element. 
ElementType The constants of this enumerated class provide a simple classification of the syntactic locations where annotations may appear in a Java program. 
FileVisitOption Defines the file tree traversal options. 
FileVisitResult The result type of a FileVisitor
FormatStyle Enumeration of the style of a localized date, time or date-time formatter. 
Formatter.BigDecimalLayoutForm Enum for BigDecimal formatting. 
Future.State Represents the computation state. 
GradientDrawable.Orientation Controls how the gradient is oriented relative to the drawable's bounds 
HijrahEra An era in the Hijrah calendar system. 
IDNA.Error IDNA error bit set values. 
ImageView.ScaleType Options for scaling the bounds of an image to the bounds of this view. 
Interpolator.Result  
IslamicCalendar.CalculationType enumeration of available calendar calculation types 
IsoEra An era in the ISO calendar system. 
JsonToken A structure, name or value type in a JSON-encoded string. 
KeyRep.Type Key type. 
Layout.Alignment  
LinkOption Defines the options as to how symbolic links are handled. 
ListFormatter.Type Type of meaning expressed by the list. 
ListFormatter.Width Verbosity level of the list patterns. 
LocalSocketAddress.Namespace The namespace that this address exists in. 
Locale.Category Enum for locale categories. 
Locale.FilteringMode This enum provides constants to select a filtering mode for locale matching. 
Locale.IsoCountryCode Enum for specifying the type defined in ISO 3166. 
LocaleDisplayNames.DialectHandling Enum used in LocaleDisplayNames.getInstance(android.icu.util.ULocale, android.icu.text.LocaleDisplayNames.DialectHandling)
Matrix.ScaleToFit Controls how the src rect should align into the dst rect for setRectToRect(). 
MeasureFormat.FormatWidth Formatting width enum. 
MeasureUnit.Complexity Enumeration for unit complexity. 
MeasureUnit.MeasurePrefix Enumeration for SI and binary prefixes, e.g. "kilo-", "nano-", "mebi-". 
MessagePattern.ApostropheMode Mode for when an apostrophe starts quoted literal text for MessageFormat output. 
MessagePattern.ArgType Argument type constants. 
MessagePattern.Part.Type Part type constants. 
MinguoEra An era in the Minguo calendar system. 
Month A month-of-year, such as 'July'. 
NetworkInfo.DetailedState This enum was deprecated in API level 29. See NetworkInfo. 
NetworkInfo.State This enum was deprecated in API level 29. See NetworkInfo. 
Normalizer.Form This enum provides constants of the four Unicode normalization forms that are described in Unicode Standard Annex #15 — Unicode Normalization Forms and two methods to access them. 
Normalizer2.Mode Constants for normalization modes. 
NumberFormatter.DecimalSeparatorDisplay An enum declaring how to render the decimal separator. 
NumberFormatter.GroupingStrategy An enum declaring the strategy for when and how to display grouping separators (i.e., the separator, often a comma or period, after every 2-3 powers of ten). 
NumberFormatter.RoundingPriority An enum declaring how to resolve conflicts between maximum fraction digits and maximum significant digits. 
NumberFormatter.SignDisplay An enum declaring how to denote positive and negative numbers. 
NumberFormatter.TrailingZeroDisplay An enum declaring how to render trailing zeros. 
NumberFormatter.UnitWidth An enum declaring how to render units, including currencies. 
NumberRangeFormatter.RangeCollapse Defines how to merge fields that are identical across the range sign. 
NumberRangeFormatter.RangeIdentityFallback Defines the behavior when the two numbers in the range are identical after rounding. 
NumberRangeFormatter.RangeIdentityResult Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range were equal or not, and whether or not the identity fallback was applied. 
NumericShaper.Range A NumericShaper.Range represents a Unicode range of a script having its own decimal digits. 
PKIXReason The PKIXReason enumerates the potential PKIX-specific reasons that an X.509 certification path may be invalid according to the PKIX (RFC 5280) standard. 
PKIXRevocationChecker.Option Various revocation options that can be specified for the revocation checking mechanism. 
Paint.Align Align specifies how drawText aligns its text relative to the [x,y] coordinates. 
Paint.Cap The Cap specifies the treatment for the beginning and ending of stroked lines and paths. 
Paint.Join The Join specifies the treatment where lines and curve segments join on a stroked path. 
Paint.Style The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color). 
Path.Direction Specifies how closed shapes (e.g. rects, ovals) are oriented when they are added to a path. 
Path.FillType Enum for the ways a path may be filled. 
Path.Op The logical operations that can be performed when combining two paths. 
PathDashPathEffect.Style  
PluralRules.PluralType Type of plurals and PluralRules. 
PorterDuff.Mode

The name of the parent class is an homage to the work of Thomas Porter and Tom Duff, presented in their seminal 1984 paper titled "Compositing Digital Images". 

PosixFilePermission Defines the bits for use with the permissions attribute. 
ProcessBuilder.Redirect.Type The type of a Redirect
Proxy.Type Represents the proxy type. 
Region.Op  
RelativeDateTimeFormatter.AbsoluteUnit Represents an absolute unit. 
RelativeDateTimeFormatter.Direction Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday" 
RelativeDateTimeFormatter.RelativeDateTimeUnit Represents the unit for formatting a relative date. 
RelativeDateTimeFormatter.RelativeUnit Represents the unit for formatting a relative date. 
RelativeDateTimeFormatter.Style The formatting style 
RenderScript.ContextType ContextType specifies the specific type of context to be created. 
RenderScript.Priority RenderScript worker thread priority enumeration. 
ResolverStyle Enumeration of different ways to resolve dates and times. 
RetentionPolicy Annotation retention policy. 
RoundingMode Specifies a rounding policy for numerical operations capable of discarding precision. 
RowIdLifetime Enumeration for RowId life-time values. 
SSLEngineResult.HandshakeStatus An SSLEngineResult enum describing the current handshaking state of this SSLEngine
SSLEngineResult.Status An SSLEngineResult enum describing the overall result of the SSLEngine operation. 
Sampler.Value  
SearchIterator.ElementComparisonType Option to control how collation elements are compared. 
Shader.TileMode  
SignStyle Enumeration of ways to handle the positive/negative sign. 
SmsMessage.MessageClass SMS Class enumeration. 
StackWalker.Option Stack walker option to configure the stack frame information obtained by a StackWalker
StandardCopyOption Defines the standard copy options. 
StandardOpenOption Defines the standard open options. 
StandardProtocolFamily Defines the standard families of communication protocols. 
SupplicantState From defs.h in wpa_supplicant
TextKeyListener.Capitalize  
TextStyle Enumeration of the style of text formatting and parsing. 
TextUtils.TruncateAt  
TextView.BufferType Type of the text buffer that defines the characteristics of the text such as static, styleable, or editable. 
ThaiBuddhistEra An era in the Thai Buddhist calendar system. 
Thread.State A thread state. 
TimeUnit A TimeUnit represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units. 
TimeZone.SystemTimeZoneType [icu] System time zone type constants used by filtering zones in TimeZone.getAvailableIDs(SystemTimeZoneType, String, Integer) 
TimeZoneFormat.GMTOffsetPatternType Offset pattern type enum. 
TimeZoneFormat.ParseOption Parse option enum, used for specifying optional parse behavior. 
TimeZoneFormat.Style Time zone display format style enum used by format/parse APIs in TimeZoneFormat
TimeZoneFormat.TimeType Time type enum used for receiving time type (standard time, daylight time or unknown) in TimeZoneFormat APIs. 
TimeZoneNames.NameType Time zone display name types 
Type.CubemapFace  
ULocale.AvailableType Types for ULocale.getAvailableLocalesByType 
ULocale.Category Enum for locale categories. 
UScript.ScriptUsage Script usage constants. 
UnicodeSet.ComparisonStyle Comparison style enums used by UnicodeSet.compareTo(UnicodeSet, ComparisonStyle)
UnicodeSet.SpanCondition Argument values for whether span() and similar functions continue while the current character is contained vs. 
UnicodeSetSpanner.CountMethod Options for replaceFrom and countIn to control how to treat each matched span. 
UnicodeSetSpanner.TrimOption Options for the trim() method 
VarHandle.AccessMode The set of access modes that specify how a variable, referenced by a VarHandle, is accessed. 
ViewDebug.HierarchyTraceType This enum was deprecated in API level 16. This enum is now unused 
ViewDebug.RecyclerTraceType This enum was deprecated in API level 16. This enum is now unused 
WebSettings.LayoutAlgorithm Enum for controlling the layout of html. 
WebSettings.PluginState The plugin state effects how plugins are treated on a page. 
WebSettings.RenderPriority  
WebSettings.TextSize This enum was deprecated in API level 15. Use WebSettings.setTextZoom(int) and WebSettings.getTextZoom() instead. 
WebSettings.ZoomDensity Enum for specifying the WebView's desired density. 
Xml.Encoding Supported character encodings. 
ZoneOffsetTransitionRule.TimeDefinition A definition of the way a local time can be converted to the actual transition date-time. 


This is the common base class of all Java language enumeration classes. More information about enums, including descriptions of the implicitly declared methods synthesized by the compiler, can be found in section {@jls 8.9} of The Java Language Specification. Enumeration classes are all serializable and receive special handling by the serialization mechanism. The serialized representation used for enum constants cannot be customized. Declarations of methods and fields that would otherwise interact with serialization are ignored, including serialVersionUID; see the Java Object Serialization Specification for details.

Note that when using an enumeration type as the type of a set or as the type of the keys in a map, specialized and efficient set and map implementations are available.

Summary

Protected constructors

Enum(String name, int ordinal)

Sole constructor.

Public methods

final int compareTo(E o)

Compares this enum with the specified object for order.

final boolean equals(Object other)

Returns true if the specified object is equal to this enum constant.

final Class<E> getDeclaringClass()

Returns the Class object corresponding to this enum constant's enum type.

final int hashCode()

Returns a hash code for this enum constant.

final String name()

Returns the name of this enum constant, exactly as declared in its enum declaration.

final int ordinal()

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

String toString()

Returns the name of this enum constant, as contained in the declaration.

static <T extends Enum<T>> T valueOf(Class<T> enumClass, String name)

Returns the enum constant of the specified enum class with the specified name.

Protected methods

final Object clone()

Throws CloneNotSupportedException.

final void finalize()

enum classes cannot have finalize methods.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

abstract int compareTo(E o)

Compares this object with the specified object for order.

Protected constructors

Enum

Added in API level 1
protected Enum (String name, 
                int ordinal)

Sole constructor. Programmers cannot invoke this constructor. It is for use by code emitted by the compiler in response to enum class declarations.

Parameters
name String: - The name of this enum constant, which is the identifier used to declare it.

ordinal int: - The ordinal of this enumeration constant (its position in the enum declaration, where the initial constant is assigned an ordinal of zero).

Public methods

compareTo

Added in API level 1
public final int compareTo (E o)

Compares this enum with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Enum constants are only comparable to other enum constants of the same enum type. The natural order implemented by this method is the order in which the constants are declared.

Parameters
o E

Returns
int

equals

Added in API level 1
public final boolean equals (Object other)

Returns true if the specified object is equal to this enum constant.

Parameters
other Object: the object to be compared for equality with this object.

Returns
boolean true if the specified object is equal to this enum constant.

getDeclaringClass

Added in API level 1
public final Class<E> getDeclaringClass ()

Returns the Class object corresponding to this enum constant's enum type. Two enum constants e1 and e2 are of the same enum type if and only if e1.getDeclaringClass() == e2.getDeclaringClass(). (The value returned by this method may differ from the one returned by the Object.getClass method for enum constants with constant-specific class bodies.)

Returns
Class<E> the Class object corresponding to this enum constant's enum type

hashCode

Added in API level 1
public final int hashCode ()

Returns a hash code for this enum constant.

Returns
int a hash code for this enum constant.

name

Added in API level 1
public final String name ()

Returns the name of this enum constant, exactly as declared in its enum declaration. Most programmers should use the toString() method in preference to this one, as the toString method may return a more user-friendly name. This method is designed primarily for use in specialized situations where correctness depends on getting the exact name, which will not vary from release to release.

Returns
String the name of this enum constant

ordinal

Added in API level 1
public final int ordinal ()

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures, such as EnumSet and EnumMap.

Returns
int the ordinal of this enumeration constant

toString

Added in API level 1
public String toString ()

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns
String the name of this enum constant

valueOf

Added in API level 1
public static T valueOf (Class<T> enumClass, 
                String name)

Returns the enum constant of the specified enum class with the specified name. The name must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)

Note that for a particular enum class T, the implicitly declared public static T valueOf(String) method on that enum may be used instead of this method to map from a name to the corresponding enum constant. All the constants of an enum class can be obtained by calling the implicit public static T[] values() method of that class.

Parameters
enumClass Class: the Class object of the enum class from which to return a constant

name String: the name of the constant to return

Returns
T the enum constant of the specified enum class with the specified name

Throws
IllegalArgumentException if the specified enum class has no constant with the specified name, or the specified class object does not represent an enum class
NullPointerException if enumClass or name is null

Protected methods

clone

Added in API level 1
protected final Object clone ()

Throws CloneNotSupportedException. This guarantees that enums are never cloned, which is necessary to preserve their "singleton" status.

Returns
Object (never returns)

finalize

Added in API level 1
protected final void finalize ()

enum classes cannot have finalize methods.