Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 461ffaa2a595fa74ee9121343f186d6986619f9b 1 parent 2816e53
nafg nafg authored
6 persistence/mapper/src/main/scala/net/liftweb/mapper/FieldFinder.scala
@@ -18,7 +18,7 @@ package net.liftweb
18 18 package mapper
19 19
20 20
21   -class FieldFinder[A <: Mapper[A], T: ClassManifest](metaMapper: Mapper[A], logger: net.liftweb.common.Logger) {
  21 +class FieldFinder[T: ClassManifest](metaMapper: AnyRef, logger: net.liftweb.common.Logger) {
22 22 import java.lang.reflect._
23 23
24 24 logger.debug("Created FieldFinder for " + classManifest[T].erasure)
@@ -30,7 +30,7 @@ class FieldFinder[A <: Mapper[A], T: ClassManifest](metaMapper: Mapper[A], logge
30 30 /**
31 31 * Find the magic mapper fields on the superclass
32 32 */
33   - def findMagicFields(onMagic: Mapper[A], staringClass: Class[_]): List[Method] = {
  33 + def findMagicFields(onMagic: AnyRef, startingClass: Class[_]): List[Method] = {
34 34 // If a class name ends in $module, it's a subclass created for scala object instances
35 35 def deMod(in: String): String =
36 36 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
100 100 meths ::: findForClass(clz.getSuperclass)
101 101 }
102 102
103   - findForClass(staringClass).distinct
  103 + findForClass(startingClass).distinct
104 104 }
105 105
106 106 lazy val accessorMethods = findMagicFields(metaMapper, metaMapper.getClass.getSuperclass)
2  persistence/mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala
@@ -1173,7 +1173,7 @@ trait MetaMapper[A<:Mapper[A]] extends BaseMetaMapper with Mapper[A] {
1173 1173
1174 1174 val mapperAccessMethods = findMagicFields(this, this.getClass.getSuperclass)
1175 1175 */
1176   - val finder = new FieldFinder[A, MappedField[_,_]](this, logger)
  1176 + val finder = new FieldFinder[MappedField[_,_]](this, logger)
1177 1177 val mapperAccessMethods = finder.accessorMethods
1178 1178
1179 1179 mappedCallbacks = mapperAccessMethods.filter(isLifecycle).map(v => (v.getName, v))
5 persistence/mapper/src/main/scala/net/liftweb/mapper/OneToMany.scala
@@ -26,9 +26,8 @@ package mapper
26 26 * @author nafg
27 27 */
28 28 trait OneToMany[K,T<:KeyedMapper[K, T]] extends KeyedMapper[K,T] { this: T =>
29   - //private var oneToManyFields: List[MappedOneToManyBase[_]] = Nil
30 29 private[mapper] lazy val oneToManyFields: List[MappedOneToManyBase[_]] = {
31   - new FieldFinder[T, MappedOneToManyBase[_]](
  30 + new FieldFinder[MappedOneToManyBase[_]](
32 31 getSingleton,
33 32 net.liftweb.common.Logger(classOf[OneToMany[K,T]])
34 33 ).accessorMethods map (_.invoke(this).asInstanceOf[MappedOneToManyBase[_]])
@@ -110,8 +109,6 @@ trait OneToMany[K,T<:KeyedMapper[K, T]] extends KeyedMapper[K,T] { this: T =>
110 109 }
111 110 protected def delegate_=(d: List[O]) = _delegate = d
112 111
113   - //oneToManyFields = this :: oneToManyFields
114   -
115 112 /**
116 113 * Takes ownership of e. Sets e's foreign key to our primary key
117 114 */

0 comments on commit 461ffaa

Please sign in to comment.
Something went wrong with that request. Please try again.