Java 类java.lang.Enum 实例源码

项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates an {@link EnumSet} using the contents of the given collection.
 * If the collection is also an {@link EnumSet}, this method works the
 * same as {@link #copyOf(EnumSet)}.  Otherwise, the elements of the collection
 * are inspected and used to populate the new set.
 *
 * @param other the collection to use to populate the new set.
 * @return an {@link EnumSet} containing elements from the given collection.
 * @throws NullPointerException if <code>other</code> is <code>null</code>.
 * @throws IllegalArgumentException if the collection is empty.
 */
public static <T extends Enum<T>> EnumSet4D<T> copyOf(Collection<T> other)
{
  if (other instanceof EnumSet)
    return ((EnumSet4D)other).clone();
  if (other.isEmpty())
      throw new IllegalArgumentException("Collection is empty");
  EnumSet4D<T> r = null;

  for (T val : other)
    {
      if (r == null)
        r = of(val);
      else
        r.add(val);
    }

  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} using the enumeration constants
 * starting from {@code from} and ending at {@code to} inclusive.
 * The two may be the same, but they must be in the correct order.
 * So giving the first constant twice would give a set with just that
 * constant set, while supplying the first and second constant will give
 * a set with those two elements.  However, specifying the second as
 * the {@code from} element followed by an earlier element as the
 * {@code to} element will result in an error.
 *
 * @param from the element to start from.
 * @param to the element to end at (may be the same as {@code from}.
 * @return an {@link EnumSet} containing the specified range of elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 * @throws IllegalArgumentException if {@code first.compareTo(last) > 0}.
 */
public static <T extends Enum<T>> EnumSet4D<T> range(T from, T to)
{
  if (from.compareTo(to) > 0)
    throw new IllegalArgumentException();
  Class<T> type = from.getDeclaringClass();
  EnumSet4D<T> r = noneOf(type);

  T[] values = type.getEnumConstants();
  // skip over values until start of range is found
  int i = 0;
  while (from != values[i])
    i++;

  // add values until end of range is found
  while (to != values[i]) {
    r.add(values[i]);
    i++;
  }

  // add end of range
  r.add(to);

  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} populated with the given elements.
 *
 * @param first the first element to use to populate the new set.
 * @param rest the other elements to use.
 * @return an {@link EnumSet} containing the elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> of(T first, T... rest)
{
  EnumSet4D<T> r = noneOf(first.getDeclaringClass());
  r.add(first);
  for (T val : rest)
    r.add(val);
  return r;
}
项目:TotalCrossSDK    文件:EnumMap4D.java   
public boolean containsKey(Object key)
{
  if (! (key instanceof Enum))
    return false;
  Enum<K> e = (Enum<K>) key;
  if (e.getDeclaringClass() != enumClass)
    return false;
  return store[e.ordinal()] != emptySlot;
}
项目:TotalCrossSDK    文件:EnumMap4D.java   
public V get(Object key)
{
  if (! (key instanceof Enum))
    return null;
  Enum<K> e = (Enum<K>) key;
  if (e.getDeclaringClass() != enumClass)
    return null;
  V o = store[e.ordinal()];
  return o == emptySlot ? null : o;
}
项目:TotalCrossSDK    文件:EnumMap4D.java   
public V remove(Object key)
{
  if (! (key instanceof Enum))
    return null;
  Enum<K> e = (Enum<K>) key;
  if (!e.getDeclaringClass().equals(enumClass))
    return null;
  V result = store[e.ordinal()];
  if (result == emptySlot)
    result = null;
  else
    --cardinality;
  store[e.ordinal()] = (V) emptySlot;
  return result;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Returns a set which is the inverse of the supplied set.
 * If a constant is present in the current set, it will not be
 * present in the new set and vice versa.
 *
 * @param other the set to provide the complement of.
 * @return an {@link EnumSet} which is the inverse of the current one.
 * @throws NullPointerException if <code>other</code> is <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> complementOf(EnumSet4D<T> other)
{
  EnumSet4D<T> r = other.clone();
  int numConstants = r.enumClass.getEnumConstants().length;
  r.store.flip(0, numConstants);
  r.cardinality = numConstants - other.cardinality;
  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} populated with the given two elements.
 *
 * @param first the first element to use to populate the new set.
 * @param second the second element to use.
 * @return an {@link EnumSet} containing the elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> of(T first, T second)
{
  EnumSet4D<T> r = of(first);
  r.add(second);
  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} populated with the given three elements.
 *
 * @param first the first element to use to populate the new set.
 * @param second the second element to use.
 * @param third the third element to use.
 * @return an {@link EnumSet} containing the elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> of(T first, T second, T third)
{
  EnumSet4D<T> r = of(first, second);
  r.add(third);
  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} populated with the given four elements.
 *
 * @param first the first element to use to populate the new set.
 * @param second the second element to use.
 * @param third the third element to use.
 * @param fourth the fourth element to use.
 * @return an {@link EnumSet} containing the elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> of(T first, T second, T third,
                                                T fourth)
{
  EnumSet4D<T> r = of(first, second, third);
  r.add(fourth);
  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Creates a new {@link EnumSet} populated with the given five elements.
 *
 * @param first the first element to use to populate the new set.
 * @param second the second element to use.
 * @param third the third element to use.
 * @param fourth the fourth element to use.
 * @param fifth the fifth element to use.
 * @return an {@link EnumSet} containing the elements.
 * @throws NullPointerException if any of the parameters are <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> of(T first, T second, T third,
                                                T fourth, T fifth)
{
  EnumSet4D<T> r = of(first, second, third, fourth);
  r.add(fifth);
  return r;
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Returns a set for the given enumeration type where
 * all the constants are present.
 *
 * @param eltType the type of enumeration to use for the set.
 * @return an {@link EnumSet} with all the bits set.
 * @throws NullPointerException if the element type is <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> allOf(Class<T> eltType)
{
  // create an EnumSet from the list of values of the type
  return copyOf(Arrays.asList(eltType.getEnumConstants()));
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Returns a set for the given enumeration type where
 * none of the constants are present.
 *
 * @param eltType the type of enumeration to use for the set.
 * @return an {@link EnumSet} with none of the bits set.
 * @throws NullPointerException if the element type is <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet4D<T> noneOf(Class<T> eltType)
{
  return complementOf(allOf(eltType));
}
项目:TotalCrossSDK    文件:EnumSet4D.java   
/**
 * Returns a clone of the given set.
 *
 * @param other the set to clone.
 * @return an {@link EnumSet} that is a clone of the given set.
 * @throws NullPointerException if <code>other</code> is <code>null</code>.
 */
public static <T extends Enum<T>> EnumSet<T> copyOf(EnumSet<T> other)
{
  return other.clone();
}
项目:asup    文件:QIndicator.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model valueRequired="true" EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean eq(E value);
项目:asup    文件:QIndicator.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model valueRequired="true" EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean ne(E value);
项目:asup    文件:QMoveable.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> void move(E value);
项目:asup    文件:QMoveable.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model clearRequired="true" EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> void move(E value, boolean clear);
项目:asup    文件:QMoveable.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> void movel(E value);
项目:asup    文件:QMoveable.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model clearRequired="true" EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> void movel(E value, boolean clear);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean eq(E value);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean ge(E value);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean gt(E value);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean le(E value);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean lt(E value);
项目:asup    文件:QNumeric.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> boolean ne(E value);
项目:asup    文件:QDataFactory.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model required="true" dataDelegateRequired="true" initializeRequired="true" EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>, D extends QBufferedData> QEnum<E, D> createEnum(Class<E> classEnumerator, D dataDelegate, boolean initialize);
项目:asup    文件:QBufferedList.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @model EBounds="org.asup.fw.java.JavaEnum"
 * @generated
 */
<E extends Enum<E>> void movea(E value);