com.namomedia.android.Enums Maven / Gradle / Ivy
package com.namomedia.android;
/**
* Enumeration utilities.
*/
class Enums {
/**
* Returns an optional enum constant for the given type, ignoring case. If the
* constant does not exist, null is returned. This function assumes that the enum values follow
* proper Java coding conventions by consisting of upper-case characters.
*/
public static > T valueIfPresent(Class enumClass, String value) {
if (value == null) {
return null;
}
try {
return Enum.valueOf(enumClass, value.toUpperCase());
} catch (IllegalArgumentException ignored) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy