It's enough to have an empty list instead of an Option[List()]
authorGeorgios Gousios <gousiosg@gmail.com>
Mon, 28 Nov 2011 08:57:15 +0000 (10:57 +0200)
committerGeorgios Gousios <gousiosg@gmail.com>
Mon, 28 Nov 2011 09:01:01 +0000 (11:01 +0200)
logic/src/main/scala/gr/grnet/aquarium/logic/accounting/dsl/DSL.scala
logic/src/main/scala/gr/grnet/aquarium/logic/accounting/dsl/DSLSemanticChecks.scala
logic/src/main/scala/gr/grnet/aquarium/logic/accounting/dsl/DSLTimeFrame.scala

index b4c7e95..5922059 100644 (file)
@@ -50,7 +50,7 @@ import java.util.Date
 trait DSL extends Loggable {
 
     /** An empty time frame*/
-    val emptyTimeFrame = DSLTimeFrame(new Date(0), None, Option(List()))
+    val emptyTimeFrame = DSLTimeFrame(new Date(0), None, List())
 
    /** An empty resource*/
    val emptyResource = DSLResource("", "", false, "")
@@ -450,8 +450,8 @@ trait DSL extends Loggable {
     }
 
     val effective = timeframe / Vocabulary.repeat match {
-      case x: YAMLListNode => Some(parseTimeFrameRepeat(x))
-      case YAMLEmptyNode => None
+      case x: YAMLListNode => parseTimeFrameRepeat(x)
+      case YAMLEmptyNode => List()
     }
 
     DSLTimeFrame(from, to, effective)
index 9903cb5..f629bc2 100644 (file)
@@ -116,12 +116,12 @@ trait DSLSemanticChecks {
   }
 
   private def checkTimeNotInitialized(time: DSLTimeFrame) : List[DSLConsistencyMsg] = {
-    if (time.repeat.get == None)
+    if (time.repeat.isEmpty)
       return List()
 
     val result = new mutable.ListBuffer[DSLConsistencyMsg]
 
-    time.repeat.get.foreach {
+    time.repeat.foreach {
       r =>
         r.start.foreach {
           r => if (r.hour == -1 || r.min == -1)
@@ -139,7 +139,7 @@ trait DSLSemanticChecks {
   }
 
   private def checkRepeatHoles(time: DSLTimeFrame) : List[DSLConsistencyMsg] = {
-    val repeat = time.repeat.getOrElse(return List())
+    val repeat = time.repeat
 
     List()
   }
index dd888e4..ee54e32 100644 (file)
@@ -45,5 +45,5 @@ import java.util.Date
 case class DSLTimeFrame (
   from: Date,
   to: Option[Date],
-  repeat: Option[List[DSLTimeFrameRepeat]]
+  repeat: List[DSLTimeFrameRepeat]
 )