1 package ejava.jpa.examples.tuning.bo; 2 3 public enum MovieRating { 4 G, 5 PG, 6 PG13("PG-13"), 7 R, 8 NC17("NC-17"); 9 10 private final String mpaa; 11 MovieRating(){ mpaa=this.name(); } 12 MovieRating(String alt) { mpaa=alt; } 13 public String mpaa() { return mpaa; } 14 15 public static MovieRating getFromMpaa(String mpaa) { 16 if (mpaa==null) { return null; } 17 for (MovieRating rating : values()) { 18 if (rating.mpaa().equals(mpaa)) { return rating; } 19 } 20 throw new IllegalArgumentException("no Movie Rating mapping for " + mpaa); 21 } 22 }