Author: xor
Date: 2008-11-16 03:10:39 +0000 (Sun, 16 Nov 2008)
New Revision: 23619

Modified:
   trunk/plugins/WoT/introduction/IntroductionPuzzle.java
Log:
Add getByID() function, small assert() fix.

Modified: trunk/plugins/WoT/introduction/IntroductionPuzzle.java
===================================================================
--- trunk/plugins/WoT/introduction/IntroductionPuzzle.java      2008-11-16 
02:36:51 UTC (rev 23618)
+++ trunk/plugins/WoT/introduction/IntroductionPuzzle.java      2008-11-16 
03:10:39 UTC (rev 23619)
@@ -129,6 +129,17 @@
                mSolution = newSolution;
        }
        
+       public static IntroductionPuzzle getByID(ObjectContainer db, UUID id) {
+               Query q = db.query();
+               q.constrain(IntroductionPuzzle.class);
+               q.descend("mID").constrain(id);
+               ObjectSet<IntroductionPuzzle> result = q.execute();
+               
+               assert(result.size() <= 1);
+               
+               return (result.hasNext() ? result.next() : null);
+       }
+       
        /**
         * Used by the IntroductionServer for downloading solutions.
         * @param db
@@ -158,7 +169,7 @@
                q.descend("mID").constrain(id);
                ObjectSet<IntroductionPuzzle> result = q.execute();
                
-               assert(result.size() == 1);
+               assert(result.size() <= 1);
                
                return (result.hasNext() ? result.next() : null);
        }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to