com.bm.introspectors
Class Property

java.lang.Object
  extended by com.bm.introspectors.Property

public class Property
extends java.lang.Object

Every persistent property of a EJB3 entity bean can be defined as field access or method access (using setter/getters). The property class abstracts from the access method and represtets a field (AccessType.FIELD) OR getter/setter (AccessType.PROPERTY)

Author:
Daniel Wiese

Constructor Summary
Property(java.lang.Class declaringClass, java.beans.PropertyDescriptor property)
          Contructor using getter/setter access.
Property(java.lang.reflect.Field fieldName)
          Contructor uing field access.
Property(FieldAnnotationMetadata metaData)
          Contructor using field access.
 
Method Summary
 boolean equals(java.lang.Object other)
          Equals.
<T extends java.lang.annotation.Annotation>
T
getAnnotation(java.lang.Class<T> annnotation)
          Returns a annotation for the current property if present.
 java.lang.Class getDeclaringClass()
          Returns the class where the property is declared.
 java.lang.Object getField(java.lang.Object instance)
          Returns a value of an field.
 java.lang.reflect.Type getGenericType()
          Returns the generic Type of this property.
 java.lang.Class<java.lang.Object> getGenericTypeClass()
          If the propety represents a genericType (e.g.
 java.lang.String getName()
          Return the name.
 java.beans.PropertyDescriptor getProperty()
          Returns the property.
 java.lang.String getPropertyName()
          Returns null if the accestype is field.
 java.lang.Class getType()
          Returns the type of the property.
 int hashCode()
          Hash Code.
 void setField(java.lang.Object instance, java.lang.Object value)
          Sets a value of the field / getterMethod.
 java.lang.String toString()
          To String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Property

public Property(java.lang.Class declaringClass,
                java.beans.PropertyDescriptor property)
Contructor using getter/setter access.

Parameters:
declaringClass - - the class wich declares the property
property - - the property descriptor

Property

public Property(FieldAnnotationMetadata metaData)
Contructor using field access. Ejb3 metadata is passed directly.

Parameters:
metaData - the ejb3 metadata information

Property

public Property(java.lang.reflect.Field fieldName)
Contructor uing field access.

Parameters:
fieldName - - der name des feldes
Method Detail

setField

public void setField(java.lang.Object instance,
                     java.lang.Object value)
              throws java.lang.IllegalAccessException
Sets a value of the field / getterMethod.

Parameters:
instance - - the instance (Typed)
value - - the new value
Throws:
java.lang.IllegalAccessException - - in error case

getField

public java.lang.Object getField(java.lang.Object instance)
                          throws java.lang.IllegalAccessException
Returns a value of an field.

Parameters:
instance - - the instance
Returns:
- the value of the paremeter of the instance
Throws:
java.lang.IllegalAccessException - - in error case

getType

public java.lang.Class getType()
Returns the type of the property.

Returns:
- the type

getGenericType

public java.lang.reflect.Type getGenericType()
Returns the generic Type of this property. E.g. id the proprty is. Collection/Order/ then Order will be returned.

Returns:
the generic Type of this property
Since:
28.10.2005

getGenericTypeClass

public java.lang.Class<java.lang.Object> getGenericTypeClass()
If the propety represents a genericType (e.g. Collection/Order/) ! Typed class thit ONE type) -> then the type is returned.

Returns:
- the type of the typed class or null

getName

public java.lang.String getName()
Return the name.

Returns:
- the name

getDeclaringClass

public java.lang.Class getDeclaringClass()
Returns the class where the property is declared.

Returns:
Returns the declaringClass.

equals

public boolean equals(java.lang.Object other)
Equals.

Overrides:
equals in class java.lang.Object
Parameters:
other - the other to compare
Returns:
- true if equal
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash Code.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code
See Also:
Object.hashCode()

getProperty

public java.beans.PropertyDescriptor getProperty()
Returns the property.

Returns:
Returns the property.

getPropertyName

public java.lang.String getPropertyName()
Returns null if the accestype is field.

Returns:
Returns the propertyName.

getAnnotation

public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annnotation)
Returns a annotation for the current property if present.

Type Parameters:
T - the annotation type.
Parameters:
annnotation - the annotation class
Returns:
the annotation instance

toString

public java.lang.String toString()
To String.

Overrides:
toString in class java.lang.Object
Returns:
- formatted string
See Also:
Object.toString()


Copyright © 2008. All Rights Reserved.