src/Pure/library.scala
changeset 72214 5924c1da3c45
parent 71864 bfc120aa737a
child 73120 c3589f2dff31
equal deleted inserted replaced
72213:6157757bb133 72214:5924c1da3c45
   274   def proper_string(s: String): Option[String] =
   274   def proper_string(s: String): Option[String] =
   275     if (s == null || s == "") None else Some(s)
   275     if (s == null || s == "") None else Some(s)
   276 
   276 
   277   def proper_list[A](list: List[A]): Option[List[A]] =
   277   def proper_list[A](list: List[A]): Option[List[A]] =
   278     if (list == null || list.isEmpty) None else Some(list)
   278     if (list == null || list.isEmpty) None else Some(list)
       
   279 
       
   280 
       
   281   /* reflection */
       
   282 
       
   283   def is_subclass[A, B](a: Class[A], b: Class[B]): Boolean =
       
   284   {
       
   285     @tailrec def subclass(c: Class[_]): Boolean =
       
   286     {
       
   287       c == b ||
       
   288         {
       
   289           val d = c.getSuperclass
       
   290           d != null && subclass(d)
       
   291         }
       
   292     }
       
   293     subclass(a)
       
   294   }
   279 }
   295 }