Permalink
Browse files

Mapper: Make FieldFinder more generic (no requirement to be Mapper)

  • Loading branch information...
1 parent 2816e53 commit 461ffaa2a595fa74ee9121343f186d6986619f9b @nafg nafg committed May 25, 2011
@@ -18,7 +18,7 @@ package net.liftweb
package mapper
-class FieldFinder[A <: Mapper[A], T: ClassManifest](metaMapper: Mapper[A], logger: net.liftweb.common.Logger) {
+class FieldFinder[T: ClassManifest](metaMapper: AnyRef, logger: net.liftweb.common.Logger) {
import java.lang.reflect._
logger.debug("Created FieldFinder for " + classManifest[T].erasure)
@@ -30,7 +30,7 @@ class FieldFinder[A <: Mapper[A], T: ClassManifest](metaMapper: Mapper[A], logge
/**
* Find the magic mapper fields on the superclass
*/
- def findMagicFields(onMagic: Mapper[A], staringClass: Class[_]): List[Method] = {
+ def findMagicFields(onMagic: AnyRef, startingClass: Class[_]): List[Method] = {
// If a class name ends in $module, it's a subclass created for scala object instances
def deMod(in: String): String =
if (in.endsWith("$module")) in.substring(0, in.length - 7)
@@ -100,7 +100,7 @@ class FieldFinder[A <: Mapper[A], T: ClassManifest](metaMapper: Mapper[A], logge
meths ::: findForClass(clz.getSuperclass)
}
- findForClass(staringClass).distinct
+ findForClass(startingClass).distinct
}
lazy val accessorMethods = findMagicFields(metaMapper, metaMapper.getClass.getSuperclass)
@@ -1173,7 +1173,7 @@ trait MetaMapper[A<:Mapper[A]] extends BaseMetaMapper with Mapper[A] {
val mapperAccessMethods = findMagicFields(this, this.getClass.getSuperclass)
*/
- val finder = new FieldFinder[A, MappedField[_,_]](this, logger)
+ val finder = new FieldFinder[MappedField[_,_]](this, logger)
val mapperAccessMethods = finder.accessorMethods
mappedCallbacks = mapperAccessMethods.filter(isLifecycle).map(v => (v.getName, v))
@@ -26,9 +26,8 @@ package mapper
* @author nafg
*/
trait OneToMany[K,T<:KeyedMapper[K, T]] extends KeyedMapper[K,T] { this: T =>
- //private var oneToManyFields: List[MappedOneToManyBase[_]] = Nil
private[mapper] lazy val oneToManyFields: List[MappedOneToManyBase[_]] = {
- new FieldFinder[T, MappedOneToManyBase[_]](
+ new FieldFinder[MappedOneToManyBase[_]](
getSingleton,
net.liftweb.common.Logger(classOf[OneToMany[K,T]])
).accessorMethods map (_.invoke(this).asInstanceOf[MappedOneToManyBase[_]])
@@ -110,8 +109,6 @@ trait OneToMany[K,T<:KeyedMapper[K, T]] extends KeyedMapper[K,T] { this: T =>
}
protected def delegate_=(d: List[O]) = _delegate = d
- //oneToManyFields = this :: oneToManyFields
-
/**
* Takes ownership of e. Sets e's foreign key to our primary key
*/

0 comments on commit 461ffaa

Please sign in to comment.