[jboss-cvs] JBossAS SVN: r84344 - projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 17 23:17:53 EST 2009
Author: scott.stark at jboss.org
Date: 2009-02-17 23:17:53 -0500 (Tue, 17 Feb 2009)
New Revision: 84344
Modified:
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaType.java
Log:
JBMAN-56, update isValue check to include EnumValue instances
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaType.java 2009-02-18 04:16:38 UTC (rev 84343)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaType.java 2009-02-18 04:17:53 UTC (rev 84344)
@@ -101,16 +101,31 @@
return true;
}
+ /**
+ * Validate that obj is a SimpleValue.STRING or EnumValue whose string
+ * value is in the set of valid enum strings.
+ * @return true if obj is a valid enum string for this type.
+ */
@Override
public boolean isValue(Object obj)
{
- if (obj == null || obj instanceof SimpleValue == false)
+ if (obj == null || (obj instanceof SimpleValue == false && obj instanceof EnumValue == false))
return false;
- SimpleValue value = (SimpleValue) obj;
- if (SimpleMetaType.STRING == value.getMetaType() == false)
- return false;
- return validValues.contains(value.getValue());
+ String enumString = null;
+ if(obj instanceof SimpleValue)
+ {
+ SimpleValue value = SimpleValue.class.cast(obj);
+ if (SimpleMetaType.STRING == value.getMetaType() == false)
+ return false;
+ enumString = value.getValue().toString();
+ }
+ else
+ {
+ EnumValue value = EnumValue.class.cast(obj);
+ enumString = value.getValue();
+ }
+ return validValues.contains(enumString);
}
@Override
More information about the jboss-cvs-commits
mailing list