All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.common.utils.EnumUtils Maven / Gradle / Ivy

There is a newer version: 4.7.2
Show newest version
package org.onetwo.common.utils;

import java.util.List;


final public class EnumUtils { 
	
	public static String[] asStrings(Enum... enums){
		String[] strings = new String[enums.length];
		for (int i = 0; i < strings.length; i++) {
			strings[i] = enums[i].toString();
		}
		return strings;
	}
	
	public static int[] asInts(Enum... enums){
		int[] ints = new int[enums.length];
		for (int i = 0; i < ints.length; i++) {
			ints[i] = enums[i].ordinal();
		}
		return ints;
	}
	
	public static > List asEnumList(Class clazz, String...strings){
		List enums = LangUtils.newArrayList(strings.length);
		for (int i = 0; i < strings.length; i++) {
			enums.add(Enum.valueOf(clazz, strings[i]));
		}
		return enums;
	}
	
	private EnumUtils(){
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy