cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1417894 - in /cxf/trunk/rt/rs/extensions/search/src: main/java/org/apache/cxf/jaxrs/ext/search/client/ test/java/org/apache/cxf/jaxrs/ext/search/client/
Date Thu, 06 Dec 2012 14:09:30 GMT
Author: sergeyb
Date: Thu Dec  6 14:09:29 2012
New Revision: 1417894

URL: http://svn.apache.org/viewvc?rev=1417894&view=rev
Log:
Adding a couple of shortcuts to SearchConditionBuilder

Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/CompleteCondition.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/CompleteCondition.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/CompleteCondition.java?rev=1417894&r1=1417893&r2=1417894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/CompleteCondition.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/CompleteCondition.java
Thu Dec  6 14:09:29 2012
@@ -25,9 +25,15 @@ public interface CompleteCondition {
     /** Conjunct current expression with another */
     PartialCondition and();
 
+    /** shortcut for and().is() */
+    Property and(String name);
+    
     /** Disjunct current expression with another */
     PartialCondition or();
 
+    /** shortcut for or().is() */
+    Property or(String name);
+    
     /** Finalize condition construction and build search condition query. */
     String query();
 }

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java?rev=1417894&r1=1417893&r2=1417894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
Thu Dec  6 14:09:29 2012
@@ -249,11 +249,19 @@ public class FiqlSearchConditionBuilder 
             result += FiqlParser.AND;
             return this;
         }
+        
+        public Property and(String name) {
+            return and().is(name);
+        }
 
         public PartialCondition or() {
             result += FiqlParser.OR;
             return this;
         }
+        
+        public Property or(String name) {
+            return or().is(name);
+        }
 
         public CompleteCondition and(CompleteCondition c1, CompleteCondition c2, CompleteCondition...
cn) {
             result += "(" + ((Builder)c1).buildPartial(this) + FiqlParser.AND

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java?rev=1417894&r1=1417893&r2=1417894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
Thu Dec  6 14:09:29 2012
@@ -255,7 +255,13 @@ public class FiqlSearchConditionBuilderT
     public void testOrSimple() {
         String ret = b.is("foo").greaterThan(20).or().is("foo").lessThan(10).query();
         assertEquals("foo=gt=20,foo=lt=10", ret);
-    }    
+    }
+    
+    @Test
+    public void testOrSimpleShortcut() {
+        String ret = b.is("foo").greaterThan(20).or("foo").lessThan(10).query();
+        assertEquals("foo=gt=20,foo=lt=10", ret);
+    }
     
     @Test
     public void testAndSimple() {
@@ -264,6 +270,12 @@ public class FiqlSearchConditionBuilderT
     }
     
     @Test
+    public void testAndSimpleShortcut() {
+        String ret = b.is("foo").greaterThan(20).and("bar").equalTo("plonk").query();
+        assertEquals("foo=gt=20;bar==plonk", ret);
+    }
+    
+    @Test
     public void testOrComplex() {
         String ret = b.or(b.is("foo").equalTo("aaa"), b.is("bar").equalTo("bbb")).query();
         assertEquals("(foo==aaa,bar==bbb)", ret);



Mime
View raw message