private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
@MarshalsValue public static <T extends Enum<T>> T toObject(Class<T> cls, int ordinal, long flags) { T[] values = Enum.getSharedConstants(cls); if (values.length == 0) { throw new AssertionError("Enum class has no values!"); } if (ordinal < 0 || ordinal >= values.length) { Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with ordinal " + ordinal + " in " + enumType.getName()); } return values[ordinal]; }
throw new NullPointerException("name == null"); T[] values = getSharedConstants(enumType); if (values == null) { throw new IllegalArgumentException(enumType + " is not an enum type");
@MarshalsValue public static <T extends Enum<T> & ValuedEnum> ValuedEnum toObject(Class<T> cls, long value, long flags) { T[] values = Enum.getSharedConstants(cls); int length = values.length; if (length == 0) { throw new AssertionError("Enum class has no values!"); } for (int i = 0; i < length; i++) { Enum<?> e = values[i]; ValuedEnum v = (ValuedEnum) e; if (v.value() == value) { return v; } } Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with value " + value + " (0x" + Long.toHexString(value) + ") found in " + enumType.getName()); }
/** * Creates an empty enum set. The permitted elements are of type * Class<E>. * * @param elementType * the class object for the elements contained. * @return an empty enum set, with permitted elements of type {@code * elementType}. * @throws ClassCastException * if the specified element type is not and enum type. */ public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) { if (!elementType.isEnum()) { throw new ClassCastException(elementType.getClass().getName() + " is not an Enum"); } E[] enums = Enum.getSharedConstants(elementType); if (enums.length <= 64) { return new MiniEnumSet<E>(elementType, enums); } return new HugeEnumSet<E>(elementType, enums); }
private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
private void initialization(Class<K> type) { keyType = type; keys = Enum.getSharedConstants(keyType); enumSize = keys.length; values = new Object[enumSize]; hasMapping = new boolean[enumSize]; }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
@MarshalsValue public static <T extends Enum<T>> T toObject(Class<T> cls, int ordinal, long flags) { T[] values = Enum.getSharedConstants(cls); if (values.length == 0) { throw new AssertionError("Enum class has no values!"); } if (ordinal < 0 || ordinal >= values.length) { Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with ordinal " + ordinal + " in " + enumType.getName()); } return values[ordinal]; }
@MarshalsValue public static <T extends Enum<T>> T toObject(Class<T> cls, int ordinal, long flags) { T[] values = Enum.getSharedConstants(cls); if (values.length == 0) { throw new AssertionError("Enum class has no values!"); } if (ordinal < 0 || ordinal >= values.length) { Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with ordinal " + ordinal + " in " + enumType.getName()); } return values[ordinal]; }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
/** * Returns the {@code enum} constants associated with this {@code Class}. * Returns {@code null} if this {@code Class} does not represent an {@code * enum} type. */ @SuppressWarnings("unchecked") // we only cast after confirming that this class is an enum public T[] getEnumConstants() { if (!isEnum()) { return null; } return (T[]) Enum.getSharedConstants((Class) this).clone(); }
@MarshalsValue public static <T extends Enum<T>> T toObject(Class<T> cls, int ordinal, long flags) { T[] values = Enum.getSharedConstants(cls); if (values.length == 0) { throw new AssertionError("Enum class has no values!"); } if (ordinal < 0 || ordinal >= values.length) { Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with ordinal " + ordinal + " in " + enumType.getName()); } return values[ordinal]; }
@MarshalsValue public static <T extends Enum<T>> T toObject(Class<T> cls, int ordinal, long flags) { T[] values = Enum.getSharedConstants(cls); if (values.length == 0) { throw new AssertionError("Enum class has no values!"); } if (ordinal < 0 || ordinal >= values.length) { Class<?> enumType = values[0].getClass(); throw new IllegalArgumentException("No constant with ordinal " + ordinal + " in " + enumType.getName()); } return values[ordinal]; }