001    /*
002     * To change this template, choose Tools | Templates
003     * and open the template in the editor.
004     */
005    
006    package org.bridj;
007    
008    import java.util.Collections;
009    import java.util.Iterator;
010    
011    /**
012     * Interface for Java enumerations that have an integral value associated
013     * @author ochafik
014     * @param <E> type of the enum
015     */
016    public interface ValuedEnum<E extends Enum<E>> extends Iterable<E> {
017        long value();
018    //
019    //    public static class EnumWrapper<EE extends Enum<EE>> implements ValuedEnum<EE> {
020    //        EE enumValue;
021    //        public EnumWrapper(EE enumValue) {
022    //            if (enumValue == null)
023    //                throw new IllegalArgumentException("Null enum value !");
024    //            this.enumValue = enumValue;
025    //        }
026    //
027    //        @Override
028    //        public long value() {
029    //            return enumValue.ordinal();
030    //        }
031    //
032    //        @Override
033    //        public Iterator<EE> iterator() {
034    //            return Collections.singleton(enumValue).iterator();
035    //        }
036    //
037    //    }
038    //
039    //    public enum MyEnum implements ValuedEnum<MyEnum> {
040    //        A(1), B(2);
041    //
042    //        MyEnum(long value) { this.value = value; }
043    //        long value;
044    //        @Override
045    //        public long value() {
046    //            return ordinal();
047    //        }
048    //
049    //        @Override
050    //        public Iterator<MyEnum> iterator() {
051    //            return Collections.singleton(this).iterator();
052    //        }
053    //
054    //        public static ValuedEnum<MyEnum> fromValue(long value) {
055    //            return FlagSet.fromValue(value, values());
056    //        }
057    //    }
058    }