Last update: 2011-06-23

org.proteios
Class AttributeDefinition

java.lang.Object
  extended by org.proteios.AttributeDefinition

public class AttributeDefinition
extends Object

An attribute is defined by it's set and get methods. This class defines such attributes. E.g. a String attribute 'name' would be defined as

 AttributeDefinition nameA = new AttributeDefinition(String.class, "Name");
 
a boolean attribute would look like
 AttributeDefinition hiddenA = new AttributeDefinition(Boolean.class, "Hidden",
        "is", "set");
 
meaning that the attribute Hidden is accessible through isHidden() and setHidden(Boolean) methods.

Author:
gregory
See Also:
ClassDescriptor

Constructor Summary
AttributeDefinition(Class describedClass, Class type, String key)
          Creates a method key where read prefix is 'get' and write prefix is 'set'
AttributeDefinition(Class describedClass, Class type, String key, AttributeReader reader)
          Creates a method key where read prefix is 'get' and write prefix is 'set' with an attribute reader that reads a value from this attribute type.
AttributeDefinition(Class describedClass, Class type, String key, String readPrefix, String writePrefix)
           
 
Method Summary
 boolean equals(Object obj)
          A defined attribute is equal to another if the keys are the same.
 Class getAttributeType()
           
 Class getDescribedClass()
           
 String getKey()
           
 AttributeReader getReader()
           
 String getReadMethodName()
           
 String getWriteMethodName()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeDefinition

public AttributeDefinition(Class describedClass,
                           Class type,
                           String key)
Creates a method key where read prefix is 'get' and write prefix is 'set'

Parameters:
describedClass -
type - of this attribute value
key - identifying this attribute

AttributeDefinition

public AttributeDefinition(Class describedClass,
                           Class type,
                           String key,
                           AttributeReader reader)
Creates a method key where read prefix is 'get' and write prefix is 'set' with an attribute reader that reads a value from this attribute type.

Parameters:
describedClass -
type - of this attribute value
key - identifying this attribute
reader - the reader that reads an attribute from this attribute e.g. the name of a Nameable type

AttributeDefinition

public AttributeDefinition(Class describedClass,
                           Class type,
                           String key,
                           String readPrefix,
                           String writePrefix)
Parameters:
describedClass -
type - of this attribute value
key - identifying this attribute
readPrefix - e.g. 'get' or 'is' for boolean values
writePrefix - e.g. 'set'
Method Detail

getKey

public String getKey()
Returns:
the key identifying this attribute

getReadMethodName

public String getReadMethodName()
Returns:
concatenated string of readPrefix and key

getWriteMethodName

public String getWriteMethodName()
Returns:
concatenated string of writePrefix and key

getAttributeType

public Class getAttributeType()

equals

public boolean equals(Object obj)
A defined attribute is equal to another if the keys are the same.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getDescribedClass

public Class getDescribedClass()

getReader

public AttributeReader getReader()

Last update: 2011-06-23