Check Enum in Java

How to Check Enum is Valid for given input

In many cases before using enum in our coding we need to check when the given value is member of the group or not. Here this Java will help to check the given valid is available in the enum or not.

public enum Factors {
YES("Yes"),
NO("No");
private static final Map<String, Factors> lookup = new HashMap<String, Factors>();
private final String factorStatus;
Factors(String factorStatus) {
this.factorStatus = factorStatus;
lookup.put(fruitname, Fruit);
}
public String factorStatus() {return this.factorStatus;}

public static Factors fromFactor(String factorStatus) {
return lookup.get(factorStatus);
}
}


Related Topic Array Search in Java
How to Generate RSS Feed for Website
How to Check Java Version on Linux / unix
Java Regex Find Numbers in String Code Example
Java Enum Example
Java  enum  

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback