[jboss-user] [JBoss Seam] - Re: Accessing Enum with EL

menashe do-not-reply at jboss.com
Thu Jan 3 17:55:40 EST 2008


that is what i do now but this is not very efficient since it had to create enum object from string all the time (i can add each enum constant to the named class but it can be tedious when there are lots of enums)

	public boolean isGood(final String value) {
  | 		return status.equals(value);
  | 	}
and this has to be added to each enum class (with Status.class updated to reflect the actuall class)
	public boolean equals(final String value) {
  | 		if (value == null || value.length() == 0) {
  | 			return false;
  | 		}
  | 		try {
  | 			if (this == Enum.valueOf(Status.class, value)){
  | 				return true;
  | 			}
  | 		} catch (final IllegalArgumentException iae) {
  | 			return false;
  | 		}
  | 		return false;
  | 	}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116893#4116893

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116893



More information about the jboss-user mailing list