Interface EnumWithIntegerValue
- All Known Implementing Classes:
AttributeStatus.Enumerated, EKCertificateGenerationLocation.Enumerated, EKGenerationLocation.Enumerated, EKGenerationType.Enumerated, EvaluationAssuranceLevel.Enumerated, EvaluationStatus.Enumerated, MeasurementRootType.Enumerated, PlatformFirmwareCapabilities.Enumerated, PlatformFirmwareSignatureVerification.Enumerated, PlatformFirmwareUpdateCompliance.Enumerated, PlatformHardwareCapabilities.Enumerated, RTMTypes.Enumerated, SecurityLevel.Enumerated, StrengthOfFunction.Enumerated
public interface EnumWithIntegerValue
Interface for enums that map integer values to enums and handle conversions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Enum<T> & EnumWithIntegerValue>
List<T> decodeMask(int mask, Class<T> enumType) Decode a mask into a list of enum objects.intgetValue()Gets the int value associated with the enum constant.static <T extends Enum<T> & EnumWithIntegerValue>
TlookupName(@NonNull String name, @NonNull Class<T> enumType) Generic static method to return an enum object given its name and the enum class it belongs to.static <T extends Enum<T> & EnumWithIntegerValue>
TlookupValue(int value, @NonNull Class<T> enumType) Look up the enum object by value.
-
Method Details
-
getValue
int getValue()Gets the int value associated with the enum constant. Not the ordinal.- Returns:
- int value
-
lookupName
static <T extends Enum<T> & EnumWithIntegerValue> T lookupName(@NonNull @NonNull String name, @NonNull @NonNull Class<T> enumType) Generic static method to return an enum object given its name and the enum class it belongs to.- Type Parameters:
T- Any enum class.- Parameters:
name- Name of an enum that could be a member of the enum class.enumType- Enum class to search through. Cannot be null.- Returns:
- The first enum within enum class that matches the given name. Null if no match is found.
-
lookupValue
static <T extends Enum<T> & EnumWithIntegerValue> T lookupValue(int value, @NonNull @NonNull Class<T> enumType) Look up the enum object by value.- Type Parameters:
T- Any enum class that implements EnumWithIntegerValue.- Parameters:
value- The value to look up.enumType- The enum class to search through. Cannot be null.- Returns:
- The Enum object in T that corresponds with the value.
-
decodeMask
Decode a mask into a list of enum objects.- Type Parameters:
T- Any enum class that implements EnumWithIntegerValue.- Parameters:
mask- The integer mask to decode.enumType- The enum class to decode the mask for.- Returns:
- A list of enum objects that correspond to the set bits in the mask.
-