33import java .util .List ;
44
55import org .apache .commons .lang3 .tuple .ImmutablePair ;
6+ import org .apache .commons .lang3 .tuple .Pair ;
7+ import org .rest .client .template .impl .ClientOperations ;
68
79import com .google .common .base .Preconditions ;
810import com .google .common .collect .Lists ;
@@ -17,7 +19,7 @@ private SearchUtil(){
1719
1820 public static List < ImmutablePair < String , ? >> parseQueryString ( final String queryString ){
1921 Preconditions .checkNotNull ( queryString );
20- Preconditions .checkState ( queryString .matches ( "(id:[0-9]+)?,?(name:[0-9a-zA-Z]+)?" ) );
22+ Preconditions .checkState ( queryString .matches ( "(~? id:[0-9]+)?,?(~? name:[0-9a-zA-Z]+)?" ) );
2123
2224 final List < ImmutablePair < String , ? >> tuplesList = Lists .newArrayList ();
2325 final String [] tuples = queryString .split ( "," );
@@ -31,7 +33,7 @@ private SearchUtil(){
3133 }
3234
3335 private static ImmutablePair < String , ? > constructTuple ( final String key , final String value ){
34- if ( key .equals ( "id" ) ){
36+ if ( key .endsWith ( "id" ) ){
3537 return new ImmutablePair < String , Long >( key , Long .parseLong ( value ) );
3638 }
3739 return new ImmutablePair < String , String >( key , value );
@@ -43,7 +45,14 @@ public static String constructQueryString( final Long id, final String name ){
4345 return constructQueryString ( id , false , name , false );
4446 }
4547
46- public static String constructQueryString ( final Long id , final boolean negatedId , final String name , final boolean negatedName ){
48+ public static String constructQueryString ( final Pair < Long , ClientOperations > idOp , final Pair < String , ClientOperations > nameOp ){
49+ final Long id = ( idOp == null ) ? null : idOp .getLeft ();
50+ final boolean negatedId = ( idOp == null ) ? false : idOp .getRight ().isNegated ();
51+ final String name = ( nameOp == null ) ? null : nameOp .getLeft ();
52+ final boolean negatedName = ( nameOp == null ) ? false : nameOp .getRight ().isNegated ();
53+ return constructQueryString ( id , negatedId , name , negatedName );
54+ }
55+ static String constructQueryString ( final Long id , final boolean negatedId , final String name , final boolean negatedName ){
4756 final StringBuffer queryString = new StringBuffer ();
4857 String key = null ;
4958 if ( id != null ){
0 commit comments