Fix requirements for role history item
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 24 May 2012 14:11:24 +0000 (17:11 +0300)
committerChristos KK Loverdos <loverdos@gmail.com>
Thu, 24 May 2012 14:11:24 +0000 (17:11 +0300)
src/main/scala/gr/grnet/aquarium/computation/data/RoleHistoryItem.scala

index c617fb4..afa6deb 100644 (file)
@@ -44,23 +44,28 @@ import gr.grnet.aquarium.logic.accounting.dsl.Timeslot
  */
 
 case class RoleHistoryItem(
-                            /**
-                             * The role name.
-                             */
-                           name: String,
+    /**
+     * The role name.
+     */
+    name: String,
 
-                           /**
-                            * Validity start time for this role. The time is inclusive.
-                            */
-                           validFrom: Long,
+    /**
+     * Validity start time for this role. The time is inclusive.
+     */
+    validFrom: Long,
 
-                           /**
-                            * Validity stop time for this role. The time is exclusive.
-                            */
-                           validTo: Long = Long.MaxValue) {
+    /**
+     * Validity stop time for this role. The time is exclusive.
+     */
+    validTo: Long = Long.MaxValue) {
 
-  require(validTo > validFrom)
-  require(!name.isEmpty)
+  require(
+    validFrom <= validTo,
+    "validFrom(%s) <= validTo(%s)".format(new MutableDateCalc(validFrom), new MutableDateCalc(validFrom)))
+
+  require(name ne null, "Name is not null")
+
+  require(!name.trim.isEmpty, "Name '%s' is not empty".format(name))
 
   def timeslot = Timeslot(validFrom, validTo)