/// /// <summary> * <p>Gets an <code>Enum</code> object by class and value.</p> /// * /// * <p>This method loops through the list of <code>Enum</code>, /// * thus if there are many <code>Enum</code>s this will be /// * slow.</p> /// * </summary> /// * <param name="enumClass"> the class of the <code>Enum</code> to get </param> /// * <param name="value"> the value of the <code>Enum</code> to get </param> /// * <returns> the enum object, or null if the enum does not exist </returns> /// * <exception cref="IllegalArgumentException"> if the enum class is <code>null</code> </exception> /// protected internal static Enum getEnum(System.Type enumClass, int @value) { if (enumClass == null) { throw new ArgumentException("The Enum Class must not be null"); } IList list = Enum.getEnumList(enumClass); for (IEnumerator it = list.GetEnumerator(); it.MoveNext();) { ValuedEnum enumeration = (ValuedEnum)it.Current; if (enumeration.getValue() == @value) { return(enumeration); } } return(null); }
/// /// <summary> * <p>Gets a <code>ValuedEnum</code> object by class and value.</p> /// * </summary> /// * <param name="enumClass"> the class of the <code>Enum</code> to get </param> /// * <param name="value"> the value of the <code>Enum</code> to get </param> /// * <returns> the enum object, or null if the enum does not exist </returns> /// * <exception cref="IllegalArgumentException"> if the enum class is <code>null</code> </exception> /// public static ValuedEnum getEnum(System.Type enumClass, int @value) { return((ValuedEnum)ValuedEnum.getEnum(enumClass, @value)); }