Java Enum Sample
import java.util.Enumeration;
public enum KeyWordsEnum
{
SHIP("Ship"),
AUTO("Auto"),
TEA("Tea"),
COFFEE("Coffee"),
IPHONE("Iphone"),
CELLPHONE("Cellphone"),
private String value;
private KeyWordsEnum(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
} // end of class
Java Enum Handler
import java.util.List;
import java.util.ArrayList;
public class EnumHandler
{
private EnumHandler instance = null;
private static List keyWordList = new ArrayList
private EnumHandler() {
for( KeyWordsEnum keyWord : KeyWordsEnum.values() ) {
keyWordList.add( keyWord);
}
}
public static EnumHandler getInstance() {
if( instance == null ) {
instance = new EnumHandler();
}
return instance;
}
public static boolean checkKeyWords( String clientComments ) {
for( int i = 0; i < keyWordList.size(); i++ ) {
if( clientComments.toUpperCase().contains( keyWordList.get(i).toUpperCase() ) {
return true;
}
}
return false;
}
} // end of class