得到一个Enum类型的Collection

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Main{

public static final String VALUE_DELIMITER = ",";
@SuppressWarnings({ "rawtypes", "unchecked" })
public static final > List getAsEnumTypeCollection(
        String valueAsString, Class type) throws Exception {
    List result = new ArrayList();
    String[] valuesArray = null;

    if ((valueAsString != null) && (!valueAsString.isEmpty())
            && (type != null)) {
        valuesArray = valueAsString.split(VALUE_DELIMITER);
        for (int i = 0; i < valuesArray.length; i++) {
            result.add(StringToTypedValueHelper.getAsEnumType(
                    valuesArray[i], type));
        }
    }

    return result;
}
public static final > Object getAsEnumType(
        String valueAsString, Class type) throws Exception {
    Object result = null;

    if ((valueAsString != null) && (!valueAsString.isEmpty())
            && (type != null)) {
        result = Enum.valueOf(type, valueAsString);
    }

    return result;
}

}

你可能感兴趣的:(得到一个Enum类型的Collection)