ca.tnt.ldaputils.annotations
Interface TypeHandler

Package class diagram package TypeHandler
All Known Implementing Classes:
LdapBusiness, LdapOrganization

public interface TypeHandler

Handler interface for handling Class types that the default annotation processor for LPA does not support

MINOR TypeHandler simplification (issue-12) Created : 13-Dec-2010 12:26:00 AM MST

Author:
Trenton D. Adams

Method Summary
 List getValues(Class classType, Class refType, Object instance)
          Processes LdapEntity objects for the given classType, and return them in a list, for binding or updating.
 Object processValues(List list, Class refType)
          Processes LdapEntity objects for the given classType.
 

Method Detail

processValues

Object processValues(List list,
                     Class refType)
Processes LdapEntity objects for the given classType. For example, if we want our data stored in a Map, we would access each object in the list, grab what we think the key should be, use that as the key, and the object itself as the value, and put it into the map. The field of course would be defined something like Map aggregateField

The type handler MUST handle ALL collection types that LdapEntity aggregates are stored in, except List, SortedSet, or native java arrays. If it does not, the data simply won't be stored in the object. The data will then either be whatever your default constructor sets it to, or null. YOUR PROBLEM, not ours. ;)

Parameters:
list - the data that we need to put into a Collection of some sort.
refType - the type of the field
Returns:
the new collection defined by classType

getValues

List getValues(Class classType,
               Class refType,
               Object instance)
Processes LdapEntity objects for the given classType, and return them in a list, for binding or updating. For example, if you have a processValues() that stores attribute values in a Map, you need to be able to convert it back to a list, for binding, or updating.

If you are using the aggregate functionality, you MUST convert the attribute data back to it's original type, such as String.

The implementation MUST return a non-null List, whether empty or not; otherwise the annotation processing will throw a NullPointerException

Parameters:
classType - the Class of the field that we're trying to handle.
refType - the type of the field
instance - the instance of the field, might be a collection, or some other type
Returns:
the List of attribute values.