org.jboss.metatype.api.types
Class EnumMetaType

java.lang.Object
  extended by org.jboss.metatype.api.types.AbstractMetaType
      extended by org.jboss.metatype.api.types.EnumMetaType
All Implemented Interfaces:
Serializable, MetaType

public class EnumMetaType
extends AbstractMetaType

EnumMetaType.

Version:
$Revision: 1.1 $
Author:
Adrian Brock
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.jboss.metatype.api.types.MetaType
ALLOWED_CLASSNAMES
 
Constructor Summary
EnumMetaType(Enum<?>[] validValues)
          Create a new EnumMetaType from the Enum values.
EnumMetaType(String className, List<String> validValues)
          Create a new EnumMetaType.
 
Method Summary
 boolean equals(Object obj)
           
 List<String> getValidValues()
          Get the valid values
 boolean isEnum()
          Retrieve whether the class name of the type is an enum
protected static boolean isValid(Enum<?>[] values)
          Are enums valid.
 boolean isValue(Object obj)
          Validate that obj is a SimpleValue.STRING or EnumValue whose string value is in the set of valid enum strings.
 String toString()
           
 
Methods inherited from class org.jboss.metatype.api.types.AbstractMetaType
getClassName, getDescription, getTypeName, isArray, isCollection, isComposite, isGeneric, isPrimitive, isProperties, isSimple, isTable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumMetaType

public EnumMetaType(String className,
                    List<String> validValues)
Create a new EnumMetaType.

Parameters:
className - the class name
validValues - the valid values

EnumMetaType

public EnumMetaType(Enum<?>[] validValues)
Create a new EnumMetaType from the Enum values.

Parameters:
validValues - the valid Enum values
Method Detail

isValid

protected static boolean isValid(Enum<?>[] values)
Are enums valid.

Parameters:
values - the enums
Returns:
true if not null and not empty

getValidValues

public List<String> getValidValues()
Get the valid values

Returns:
the valid values

isEnum

public boolean isEnum()
Description copied from interface: MetaType
Retrieve whether the class name of the type is an enum

Specified by:
isEnum in interface MetaType
Overrides:
isEnum in class AbstractMetaType
Returns:
true when it is an enum or false otherwise

isValue

public boolean isValue(Object obj)
Validate that obj is a SimpleValue.STRING or EnumValue whose string value is in the set of valid enum strings.

Specified by:
isValue in interface MetaType
Specified by:
isValue in class AbstractMetaType
Parameters:
obj - the object to test
Returns:
true if obj is a valid enum string for this type.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.