Java enums
satya - 6/6/2014 10:17:30 AM
working with java enums
working with java enums
satya - 6/6/2014 10:33:59 AM
java comparing strings to enums
java comparing strings to enums
satya - 6/6/2014 10:39:01 AM
Here is an example
public class SatSectionType
{
	public enum SectionTypeEnum {
		CR1, CR2, CR3, M1, M2, M3, W1, W2, W3, G
	}
	
        //unrelated methods
	public SatSectionType(){}
	public String f_SatSectionType_id;
	public int f_number_of_questions;
	public String f_sectiontype_name;
	public String f_sectiontype_abbreviation;
	//Comparing a string to its enum value
	static boolean isM2(String type)
	{
		return (SectionTypeEnum.M2 == SectionTypeEnum.valueOf(type));
	}
}
satya - 6/6/2014 10:40:58 AM
You can do things like
//built in valueOf method
SomeEnumType x = SomeEnumType.valueOf(String x);
//Predefined statics
SomeEnumType.Option1
SomeEnumType.Option2
//etc
//Predefined collections
SomeEnumType.values() //returns an enumerable collection