Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip_1087_1088'

Fixes #1087, #1088

* wip_1087_1088:
  MappedField#canEqual: override is unnecessary
  Test #1087 -- Menu.param{s,}[T <: AnyRef]
  Test #1088 -- MappedField#equals requires getClass to equal. Also, respect scala.Equals#canEqual
  • Loading branch information...
commit 0b5068b50c7b2eadccb8aad9be4bfa54c0f2ee1e 2 parents c16413f + 2e4de02
@nafg nafg authored
View
23 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
@@ -265,7 +265,7 @@ trait MappedNullableField[NullableFieldType <: Any,OwnerType <: Mapper[OwnerType
* The strongly typed field that's mapped to a column (or many columns) in the database.
* FieldType is the type of the field and OwnerType is the Owner of the field
*/
-trait MappedField[FieldType <: Any,OwnerType <: Mapper[OwnerType]] extends TypedField[FieldType] with BaseOwnedMappedField[OwnerType] with FieldIdentifier with PSettableValueHolder[FieldType] {
+trait MappedField[FieldType <: Any,OwnerType <: Mapper[OwnerType]] extends TypedField[FieldType] with BaseOwnedMappedField[OwnerType] with FieldIdentifier with PSettableValueHolder[FieldType] with scala.Equals {
/**
* Will be set to the type of the field
@@ -673,11 +673,22 @@ trait MappedField[FieldType <: Any,OwnerType <: Mapper[OwnerType]] extends Typed
* Does the "right thing" comparing mapped fields
*/
override def equals(other: Any): Boolean = {
- other match {
- case mapped: MappedField[_, _] => this.i_is_! == mapped.i_is_!
- case ov: AnyRef if (ov ne null) && dbFieldClass.isAssignableFrom(ov.getClass) => this.is == runFilters(ov.asInstanceOf[FieldType], setFilter)
- case ov => this.is == ov
- }
+ (
+ other match {
+ case e: scala.Equals => e canEqual this
+ case _ => true}
+ ) && (
+ other match {
+ case mapped: MappedField[_, _] => this.i_is_! == mapped.i_is_!
+ case ov: AnyRef if (ov ne null) && dbFieldClass.isAssignableFrom(ov.getClass) => this.is == runFilters(ov.asInstanceOf[FieldType], setFilter)
+ case ov => this.is == ov
+ }
+ )
+ }
+
+ def canEqual(that: Any) = that match {
+ case ar: AnyRef => ar.getClass==this.getClass
+ case _ => false
}
override def asHtml : Node = Text(toString)
View
8 web/webkit/src/main/scala/net/liftweb/sitemap/Menu.scala
@@ -91,7 +91,7 @@ object Menu extends MenuSingleton {
* An intermediate class that holds the basic stuff that's needed to make a Menu item for SiteMap.
* You must include at least one URI path element by calling the / method
*/
- class PreParamMenu[T](name: String, linkText: Loc.LinkText[T], parser: String => Box[T], encoder: T => String) {
+ class PreParamMenu[T<:AnyRef](name: String, linkText: Loc.LinkText[T], parser: String => Box[T], encoder: T => String) {
/**
* The method to add a path element to the URL representing this menu item
*/
@@ -219,7 +219,7 @@ object Menu extends MenuSingleton {
* An intermediate class that holds the basic stuff that's needed to make a Menu item for SiteMap.
* You must include at least one URI path element by calling the / method
*/
- class PreParamsMenu[T](name: String, linkText: Loc.LinkText[T],
+ class PreParamsMenu[T<:AnyRef](name: String, linkText: Loc.LinkText[T],
parser: List[String] => Box[T],
encoder: T => List[String]) {
/**
@@ -559,11 +559,11 @@ sealed trait MenuSingleton {
*/
def i(nameAndLink: String): PreMenu = Menu.apply(nameAndLink, S ? nameAndLink)
- def param[T](name: String, linkText: Loc.LinkText[T], parser: String => Box[T],
+ def param[T<:AnyRef](name: String, linkText: Loc.LinkText[T], parser: String => Box[T],
encoder: T => String): PreParamMenu[T] =
new PreParamMenu[T](name, linkText, parser, encoder)
- def params[T](name: String, linkText: Loc.LinkText[T],
+ def params[T<:AnyRef](name: String, linkText: Loc.LinkText[T],
parser: List[String] => Box[T],
encoder: T => List[String]): PreParamsMenu[T] =
new PreParamsMenu[T](name, linkText, parser, encoder)
Please sign in to comment.
Something went wrong with that request. Please try again.